China Jiliang University Java. Programming in Java. Java Swing Programming. Java Web Applications, Helmut Dispert

Size: px
Start display at page:

Download "China Jiliang University Java. Programming in Java. Java Swing Programming. Java Web Applications, Helmut Dispert"

Transcription

1 Java Programming in Java Java Swing Programming

2 Java Swing Design Goals The overall goal for the Swing project was: To build a set of extensible GUI components to enable developers to more rapidly develop powerful Java front ends for commercial applications. The design goals mandated that Swing would: 1. Be implemented entirely in Java to promote cross-platform consistency and easier maintenance. 2. Provide a single API capable of supporting multiple look-and-feels so that developers and end-users would not be locked into a single look-and-feel. Enable the power of model-driven programming without requiring it in the highest-level API. 3. Adhere to JavaBeans design principles to ensure that components behave well in IDEs and builder tools. 4. Provide compatibility with AWT APIs where there is overlapping, to leverage the AWT knowledge base and ease porting. Ref.: Sun Microsystems

3 Contents Introduction History JFC Java Foundation Classes What makes Swing so special? Lightweight Components PLAF MVC Delegation Event Model How to use Swing Components JComponent Layouts Example Summary

4 AWT Problems with the AWT AWT is not functional enough for full scale applications small widget library widgets have only basic functionality extensions commonly needed AWT Components rely on native peers no platform independency: widgets do not perform exactly the same on different platforms Widget = Window Gadget

5 AWT vs. Swing APIs Java AWT (Abstract Windowing Toolkit) Package: java.awt GUI functionality (graphical user interface) Component libraries: labels, buttons, textfields, etc. (platform dependent) Helper classes: event handling, layout managers (window layouts), etc. The Swing APIs Package: javax.swing Greater platform independence - portable "look and feel" (buttons, etc.) AWT and Swing are part of the JFC (Java Foundation Classes) Easy upgrading using "J": Applet JApplet Button JButton

6 Classes, Packages java.lang.object java.awt.component java.awt.container java.awt.panel java.applet.applet Component Container Panel Applet

7 Class JApplet java.lang.object java.awt.component java.awt.container java.awt.panel java.applet.applet javax.swing.japplet Class JApplet: An extended version of java.applet.applet that adds support for the JFC/Swing component architecture. Component Container Panel Applet JApplet

8 Classes, Packages Syntax: public class Name extends java.applet.applet {... } imported package class

9 JFC Java Foundation Classes AWT Swing Accessibility 2D API Drag and Drop AWT: the original GUI toolkit Swing: the new GUI toolkit Accessibility: tools to develop support for users challenged by traditional UI s 2D API: classes for more complex use of painting, shape, colour, and fonts Drag and Drop: tools for implementing the transfer of information between Java applications and native applications

10 JFC Java Foundation Classes consist of: Abstract Windowing Toolkit (AWT) Swing Since JDK1.2 Lightweight Components (without OS support) The Swing Class library based on AWT, expansion with components and the Model-View-Controller (MVC) Java 2D Image Design, 2D Graphics, GUI Design (Graphical User Interfaces) Drag and Drop Drag and Drop with mouse control Accessibility Interface to include additional I/O-devices. continued

11 JFC Java Foundation Classes consist of: Abstract Windowing Toolkit (AWT) Heavyweight Components (using OS-based function) Includes three elements Components UI elements Example: Buttons, Labels,... Container Grouping of UI elements Example: Window Layout Manager Decide how components will be organized and accessed in the container Example: Border Layout (Nord, Süd, Ost, West, Center)

12 AWT Architecture of the Swing Class Library OS-independent part of API OS-dependent part of API Motif ButtonPeer Button ButtonPeer Windows ButtonPeer The button peer interface specifies the methods that all implementations of Abstract Window Toolkit buttons must define.

13 Swing Components Concept of Java peers: When instantiating an AWT component the native environment creates the component. User sees the native look-and-feel, component acts like the native control. Peer: native code that provides this look-and-feel. Each platform has its own set of peers. Example: A Java button appears (and acts) as a Windows button under Windows, as a Macintosh button under Macintosh, and as a Unix button under Unix. Problem: Not all native controls respond in the same way to the same events, so that a Java program shows different behavior under different Java AWT environments. Solution: Lightweight components, written entirely in Java. Swing provides a set of pure Java lightweight components, ensuring better cross-platform compatibility. A lightweight component subclasses java.awt.component - implementing the look-and-feel of the component in Java rather than delegating the lookand-feel to a native peer.

14 AWT Architecture of the Swing Class Library Heavyweight Komponenten (AWT) Interface of the components with so-called peer-objects, that have to be rewritten for each operationg system (OS) Lightweight Komponenten (Swing) Directly programmed in Java Container Classes (Frame, Dialog, Window, Applet) come from AWT and were expanded: JFrame, JDialog, JWindow, JApplet as toplevel Container All lightweight components can directly be drawn in the Frame.

15 AWT AWT - Heavyweight Components Rectangular Opaque Always drawn over top of lightweight components Rely on native peers Look and Feel tied to operating system functionality determined by operating system faster, because the OS handles the work

16 Swing Swing - Lightweight Components Swing uses lightweight components It uses a variant of the Model View Controller Architecture (MVC) It has Pluggable Look And Feel (PLAF) It uses the Delegation Event Model

17 Swing Swing - Lightweight Components Any shape Transparent portions Overlap Mouse events fall through transparent portions Do not rely on native peers Look and Feel drawn at runtime so can vary functionality is the same on all platforms slower because Java has to do the work

18 Swing Lightweight vs. Heavyweight

19 Model View Controller Roots in MVC Swing architecture is rooted in the model-view-controller (MVC) design that dates back to SmallTalk. MVC architecture calls for a visual application to be broken up into three separate parts: A model that represents the data for the application. The view that is the visual representation of that data. A controller that takes user input on the view and translates that to changes in the model.

20 Model View Controller Independent MVC-elements: Model state data for each component different data for different models View how the component looks onscreen, displays the data Controller dictates how the component reacts to I/O events Controller Model View

21 Model View Controller State Query Change Notification Model Encapsulates Encapsulates application application state state Responds Responds to to state state queries queries Exposes Exposes application application functionality functionality Notifies Notifies views views of of changes changes State Change View Renders Renders the the models models Requests Requests updates updates from from models models Sends Sends user user gestures gestures to to controller controller Allows Allows controller controller to to select select view view View Selection User Gestures Controller Defines Defines application application behaviour behaviour Maps Maps user user actions actions to to model model updates updates Selects Selects view view for for response response One One for for each each functionality functionality Method Invocations Events

22 Modified MVC UI Delegate The Java Swing Architecture uses a modified MVC-model in which the "view" and "controller" are combined in a so-called UI object (User-interface). Component M UI Object UI Manager The UI Object is also called the "UI delegate" or the "delegate object". The modified MVC-model is also referred to a "separable model architecture".

23 Modified MVC UI Delegate Example: JButton ButtonUI Controller View JButton Button Model

24 Modified MVC UI Delegate Example: JButton - Pluggable Look and Feel(PLAF) ButtonUI Controller View UIFactory JButton Button Model

25 Modified MVC UI Delegate Swing Look & Feel AWT Look & Feel JComponent (MVC Model) Component MVC View MVC Controller Peer (native) ComponentUI (Delegate) Platform Widget (native)

26 Swing Components and Container

27 Swing Packages Important Swing Packages: javax.accessibility Provides accessibility for disabled persons javax.swing Provides a set of "lightweight" (all-java language) components that, to the maximum degree possible, work the same on all platforms. javax.swing.border Provides classes and interface for drawing specialized borders around a Swing component. javax.swing.event Provides for events fired by Swing components. javax.swing.plaf Provides user interface objects built according to the Basic look-and-feel.

28 Swing Components: JComponent, JFrame Swing components are similar to components in the Abstract Windowing Toolkit (AWT) but are subclasses of the JComponent class. common root of most of the Swing GUI classes guiding framework for GUI objects extends java.awt.container class Swing applications are subclasses of the class JFrame.

29 Swing Components Swing components and containers are added to a content pane which represents the full frame area. The content pane is added to the frame.

30 RootPane Structure of a RootPane Menu ContentPane GlasPane LayeredPane

31 Swing Components AbstractButton ButtonGroup ImageIcon JApplet JFrame JButton JCheckBox JComboBox JLabel Abstract Superclass for Swing buttons. Encapsulates a mutually exclusive set of buttons. Encapsulates an icon. The Swing version of Applet. The Swing frame that is more sophisticated than the AWT frame. We can add components in layers, add a menu bar, or paint over the component through a component called a glass pane. The Swing push button class. The Swing check box class. Encapsulates a combo box (a combination of a drop-down list and text field). The Swing version of a Label. continued

32 Swing Components JOptionPane JPasswordField JRadioButton JScrollPane JTabbedpane JTable JTextField JTree The option panes in Swing. Option panes are dialog boxes that display some information to the user or get confirmation from the user so that the program can be executed further based on the choice the user makes. A text field that does not display the text entered into it, but displays the specified character, e.g. * as input is given into the field. The Swing version of a radio button. Encapsulates a rectangular area in which a component may be viewed. Encapsulates a tabbed window. Encapsulates a table-based control. The Swing version of a text field. Encapsulate a tree-based control.

33 Look and Feel PLAF - Pluggable Look and Feel Swing supplies three choices for look and feel: - Metal style - Swing's default cross-platform LAF - Motif X-Windows system style LAF - Windows style LAF - Mac style (not part of the JDK) - New styles can be designed - Style can be reset/changed at runtime Method: setlookandfeel(plaf)

34 Sample Program - PLAF Windows Look-and-Feel Motif Look-and-Feel Metal Look-and-Feel Java SwingExamp01

35 Sample Program - PLAF import java.awt.event.*; import java.awt.*; import javax.swing.*; public class SwingExamp01 extends Jframe implements ActionListener { private static final String[] MONTHS = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; public static void main(string[] args) { SwingExamp01 frame = new SwingExamp01(); frame.setlocation(100, 100); frame.pack(); frame.setvisible(true); }

36 Sample Program - PLAF public SwingExamp01() { super("our first Swing-Program"); //Panel zur Namenseingabe hinzufügen JPanel namepanel = new JPanel(); JLabel label = new JLabel( "Name:", new ImageIcon("triblue.gif"), SwingConstants.LEFT ); namepanel.add(label); JTextField tf = new JTextField(30); tf.settooltiptext("enter your name"); namepanel.add(tf); namepanel.setborder(borderfactory.createetchedborder()); getcontentpane().add(namepanel, BorderLayout.NORTH); //Monatsliste hinzufügen JList list = new JList(MONTHS); list.settooltiptext("select the month of your birthday"); getcontentpane().add(new JScrollPane(list), BorderLayout.CENTER); //Panel mit den Buttons hinzufügen JPanel buttonpanel = new JPanel(); JButton button1 = new JButton("Metal");

37 Sample Program - PLAF } button1.addactionlistener(this); button1.settooltiptext("metal-look-and-feel"); buttonpanel.add(button1); JButton button2 = new JButton("Motif"); button2.addactionlistener(this); button2.settooltiptext("motif-look-and-feel"); buttonpanel.add(button2); JButton button3 = new JButton("Windows"); button3.addactionlistener(this); button3.settooltiptext("windows-look-and-feel"); buttonpanel.add(button3); buttonpanel.setborder(borderfactory.createetchedborder()); getcontentpane().add(buttonpanel, BorderLayout.SOUTH); //Windows-Listener addwindowlistener(new WindowClosingAdapter(true));

38 Sample Program - PLAF public void actionperformed(actionevent event) { String cmd = event.getactioncommand(); try { //PLAF-Klasse auswählen String plaf = "unknown"; if (cmd.equals("metal")) { plaf = "javax.swing.plaf.metal.metallookandfeel"; } else if (cmd.equals("motif")) { plaf = "com.sun.java.swing.plaf.motif.motiflookandfeel"; } else if (cmd.equals("windows")) { plaf = "com.sun.java.swing.plaf.windows.windowslookandfeel"; }

39 Sample Program - PLAF } } //LAF umschalten UIManager.setLookAndFeel(plaf); SwingUtilities.updateComponentTreeUI(this); } catch (UnsupportedLookAndFeelException e) { System.err.println(e.toString()); } catch (ClassNotFoundException e) { System.err.println(e.toString()); } catch (InstantiationException e) { System.err.println(e.toString()); } catch (IllegalAccessException e) { System.err.println(e.toString()); }

40 Layout Managers Layout Managers are used to arrange components according to predefined patterns and to allow more complex UIs.

41 Layout Managers Layout-Manager are used to render a UI: position and organize components (UI, container). Each container has a reference to an object that implements the interface LayoutManager. It can be overwritten with setlayout(layoutmanager. Components can be added to the container with add(component) and are ordered in accordingly. When top-level containerare used both methods have to called on the ContentPane.

42 Layout Managers - Flow Layout The Flow Layout arranges components in a left-to-right flow, much like lines of text in a paragraph. Flow layouts are typically used to arrange buttons in a panel. It will arrange buttons left to right until no more buttons fit on the same line. Each line is centered.

43 Layout Managers - Flow Layout import java.awt.*; import java.awt.event.*; public class Flow extends Frame { public static void main(string[] args) { Flow wnd = new Flow(); wnd.setvisible(true); } } public Flow() { super("test FlowLayout"); addwindowlistener(new WindowClosingAdapter(true)); //Layout setzen und Komponenten hinzufügen setlayout(new FlowLayout(FlowLayout.LEFT,20,20)); add(new Button("Button 1")); add(new Button("Button 2")); add(new Button("Button 3")); add(new Button("Button 4")); add(new Button("Button 5")); pack(); }

44 Layout Managers - Border Layout The BorderLayout lays out a container, arranging and resizing its components to fit in five regions: north, south, east, west, and center. Each region may contain no more than one component, and is identified by a corresponding constant: NORTH, SOUTH, EAST, WEST, and CENTER.

45 Layout Managers - Grid Layout The GridLayout lays out a container's components in a rectangular grid. The container is divided into equal-sized rectangles, and one component is placed in each rectangle.

46 Layout Managers - Grid Layout import java.awt.*; import java.awt.event.*; public class Grid extends Frame { public static void main(string[] args) { Grid wnd = new Grid(); wnd.setvisible(true); } } public Grid() { super("test GridLayout"); addwindowlistener(new WindowClosingAdapter(true)); //Layout setzen und Komponenten hinzufügen setlayout(new GridLayout(4,2)); add(new Button("Button 1")); add(new Button("Button 2")); add(new Button("Button 3")); add(new Button("Button 4")); add(new Button("Button 5")); add(new Button("Button 6")); add(new Button("Button 7")); pack(); }

47 Layout Managers - Grid Bag Layout Example: GridLayout Java

48 Layout Managers - Grid Bag Layout The GridBagLayout The GridBagLayout class is a flexible layout manager that aligns components vertically and horizontally, without requiring that the components be of the same size. Each GridBagLayout object maintains a dynamic, rectangular grid of cells, with each component occupying one or more cells, called its display area.

49 Layout Managers - Grid Bag Layout

50 Layout Managers Further Layout Manager CardLayout Can order several containers in a higher container, produces a stack of containers that are organized on top of each other. BoxLayout Similar to the FlowLayout. The components that are added to a container are ordered from top to bottom or from left to right. OverlayLayout Allows to stack components (overlaying them). ViewportLayout A viewport is a visible area of a scollable window. NullLayout Components can be positioned using predefined coordinates (absolute positioning).

51 NullLayout import java.awt.*; import java.awt.event.*; public class NullLayout extends Frame { public static void main(string[] args) { NullLayout wnd = new NullLayout(); wnd.setvisible(true); } } public NullLayout() { super("dialogelemente ohne Layoutmanager"); addwindowlistener(new WindowClosingAdapter(true)); //Layout setzen und Komponenten hinzufügen setsize(300,250); setlayout(null); for (int i = 0; i < 5; ++i) { Button button = new Button("Button"+(i+1)); button.setbounds(10+i*35,40+i*35,100,30); add(button); } } Java

52 Swing MVC Advanced Java MVC Example

53 Swing MVC Example: Simple Calculator Main program: The main program initializes everything and ties everything together. View: creates the display, calls the model as necessary to get information. Controller: Responds to user requests. It is implemented as an Observer pattern -- the Controller registers listeners that are called when the View detects a user interaction. Based on the user request, the Controller calls methods in the View and Model to accomplish the requested action. Model: independent of the user interface, performs the basic calculator function.

54 Swing MVC Main program: import javax.swing.*; public class CalcMVC { public static void main(string[] args) { CalcModel model = new CalcModel(); CalcView view = new CalcView(model); CalcController controller = new CalcController(model, view); } } view.setvisible(true); Java Create model, view, and controller

Introduction to the JAVA UI classes Advanced HCI IAT351

Introduction to the JAVA UI classes Advanced HCI IAT351 Introduction to the JAVA UI classes Advanced HCI IAT351 Week 3 Lecture 1 17.09.2012 Lyn Bartram lyn@sfu.ca About JFC and Swing JFC Java TM Foundation Classes Encompass a group of features for constructing

More information

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson)

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson) Graphics programming COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson) Overview Aims To provide an overview of Swing and the AWT To show how to build

More information

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008 Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008 Announcements A3 is up, due Friday, Oct 10 Prelim 1 scheduled for Oct 16 if you have a conflict, let us know now 2 Interactive

More information

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT CSE 143 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/

More information

All the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class.

All the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class. Q1. If you add a component to the CENTER of a border layout, which directions will the component stretch? A1. The component will stretch both horizontally and vertically. It will occupy the whole space

More information

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling Handout 12 CS603 Object-Oriented Programming Fall 15 Page 1 of 12 Handout 14 Graphical User Interface (GUI) with Swing, Event Handling The Swing library (javax.swing.*) Contains classes that implement

More information

Swing. By Iqtidar Ali

Swing. By Iqtidar Ali Swing By Iqtidar Ali Background of Swing We have been looking at AWT (Abstract Window ToolKit) components up till now. Programmers were not comfortable when doing programming with AWT. Bcoz AWT is limited

More information

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7 PROGRAMMING DESIGN USING JAVA (ITT 303) Graphical User Interface Unit 7 Learning Objectives At the end of this unit students should be able to: Build graphical user interfaces Create and manipulate buttons,

More information

Java. GUI building with the AWT

Java. GUI building with the AWT Java GUI building with the AWT AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many applications Uses the controls defined by your OS therefore

More information

Graphic User Interfaces. - GUI concepts - Swing - AWT

Graphic User Interfaces. - GUI concepts - Swing - AWT Graphic User Interfaces - GUI concepts - Swing - AWT 1 What is GUI Graphic User Interfaces are used in programs to communicate more efficiently with computer users MacOS MS Windows X Windows etc 2 Considerations

More information

Introduction to Graphical Interface Programming in Java. Introduction to AWT and Swing

Introduction to Graphical Interface Programming in Java. Introduction to AWT and Swing Introduction to Graphical Interface Programming in Java Introduction to AWT and Swing GUI versus Graphics Programming Graphical User Interface (GUI) Graphics Programming Purpose is to display info and

More information

MODEL UPDATES MANIPULATES USER

MODEL UPDATES MANIPULATES USER 1) What do you mean by MVC architecture? Explain its role in modern applications and list its advantages(may-2013,jan-2013,nov-2011). In addition to dividing the application into three kinds of components,

More information

CSE 331. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

CSE 331. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT CSE 331 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/

More information

Sri Vidya College of Engineering & Technology

Sri Vidya College of Engineering & Technology UNIT-V TWO MARKS QUESTION & ANSWER 1. What is the difference between the Font and FontMetrics class? Font class is used to set or retrieve the screen fonts.the Font class maps the characters of the language

More information

CS 251 Intermediate Programming GUIs: Components and Layout

CS 251 Intermediate Programming GUIs: Components and Layout CS 251 Intermediate Programming GUIs: Components and Layout Brooke Chenoweth University of New Mexico Fall 2017 import javax. swing.*; Hello GUI public class HelloGUI extends JFrame { public HelloGUI ()

More information

Graphical User Interfaces. Comp 152

Graphical User Interfaces. Comp 152 Graphical User Interfaces Comp 152 Procedural programming Execute line of code at a time Allowing for selection and repetition Call one function and then another. Can trace program execution on paper from

More information

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in Lab 4 D0010E Object-Oriented Programming and Design Lecture 9 Lab 4: You will implement a game that can be played over the Internet. The networking part has already been written. Among other things, the

More information

Graphical User Interfaces (GUIs)

Graphical User Interfaces (GUIs) CMSC 132: Object-Oriented Programming II Graphical User Interfaces (GUIs) Department of Computer Science University of Maryland, College Park Model-View-Controller (MVC) Model for GUI programming (Xerox

More information

Starting Out with Java: From Control Structures Through Objects Sixth Edition

Starting Out with Java: From Control Structures Through Objects Sixth Edition Starting Out with Java: From Control Structures Through Objects Sixth Edition Chapter 12 A First Look at GUI Applications Chapter Topics 12.1 Introduction 12.2 Creating Windows 12.3 Equipping GUI Classes

More information

Part 3: Graphical User Interface (GUI) & Java Applets

Part 3: Graphical User Interface (GUI) & Java Applets 1,QWURGXFWLRQWR-DYD3URJUDPPLQJ (( Part 3: Graphical User Interface (GUI) & Java Applets EE905-GUI 7RSLFV Creating a Window Panels Event Handling Swing GUI Components ƒ Layout Management ƒ Text Field ƒ

More information

Introduction p. 1 JFC Architecture p. 5 Introduction to JFC p. 7 The JFC 1.2 Extension p. 8 Swing p. 9 Drag and Drop p. 16 Accessibility p.

Introduction p. 1 JFC Architecture p. 5 Introduction to JFC p. 7 The JFC 1.2 Extension p. 8 Swing p. 9 Drag and Drop p. 16 Accessibility p. Introduction p. 1 JFC Architecture p. 5 Introduction to JFC p. 7 The JFC 1.2 Extension p. 8 Swing p. 9 Drag and Drop p. 16 Accessibility p. 17 MVC Architecture p. 19 The MVC Architecture p. 20 Combined

More information

Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI

Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI CBOP3203 Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI components like button, text input, scroll bar and others.

More information

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 5: Will be an open-ended Swing project. "Programming Contest"

More information

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun! Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Why are we studying Swing? 1. Useful & fun! 2. Good application of OOP techniques

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

Laying Out Components. What is Widget Layout?

Laying Out Components. What is Widget Layout? Laying Out Components Interior Design for GUIs What is Widget Layout? Positioning widgets in their container (typically a JPanel or a JFrame s content pane) Basic idea: each widget has a size and position

More information

Java: Graphical User Interfaces (GUI)

Java: Graphical User Interfaces (GUI) Chair of Software Engineering Carlo A. Furia, Marco Piccioni, and Bertrand Meyer Java: Graphical User Interfaces (GUI) With material from Christoph Angerer The essence of the Java Graphics API Application

More information

What is Widget Layout? Laying Out Components. Resizing a Window. Hierarchical Widget Layout. Interior Design for GUIs

What is Widget Layout? Laying Out Components. Resizing a Window. Hierarchical Widget Layout. Interior Design for GUIs What is Widget Layout? Laying Out Components Positioning widgets in their container (typically a JPanel or a JFrame s content pane) Basic idea: each widget has a size and position Main problem: what if

More information

Java Graphical User Interfaces

Java Graphical User Interfaces Java Graphical User Interfaces 1 The Abstract Windowing Toolkit (AWT) Since Java was first released, its user interface facilities have been a significant weakness The Abstract Windowing Toolkit (AWT)

More information

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming

More information

Packages: Putting Classes Together

Packages: Putting Classes Together Packages: Putting Classes Together 1 Introduction 2 The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance) Extending interfaces The features in basic

More information

CS11 Java. Fall Lecture 4

CS11 Java. Fall Lecture 4 CS11 Java Fall 2006-2007 Lecture 4 Today s Topics Interfaces The Swing API Event Handlers Inner Classes Arrays Java Interfaces Classes can only have one parent class No multiple inheritance in Java! By

More information

INTRODUCTION TO (GUIS)

INTRODUCTION TO (GUIS) INTRODUCTION TO GRAPHICAL USER INTERFACES (GUIS) Lecture 10 CS2110 Fall 2009 Announcements 2 A3 will be posted shortly, please start early Prelim 1: Thursday October 14, Uris Hall G01 We do NOT have any

More information

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages. 1 CS257 Computer Science I Kevin Sahr, PhD Lecture 14: Graphical User Interfaces Command-Line Applications 2 The programs we've explored thus far have been text-based applications A Java application is

More information

CHAPTER 2. Java Overview

CHAPTER 2. Java Overview Networks and Internet Programming (0907522) CHAPTER 2 Java Overview Instructor: Dr. Khalid A. Darabkh Objectives The objectives of this chapter are: To discuss the classes present in the java.awt package

More information

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing CSEN401 Computer Programming Lab Topics: Graphical User Interface Window Interfaces using Swing Prof. Dr. Slim Abdennadher 22.3.2015 c S. Abdennadher 1 Swing c S. Abdennadher 2 AWT versus Swing Two basic

More information

CSE 331. Event- driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

CSE 331. Event- driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT CSE 331 Event- driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT Lecturer: Michael Hotan slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer,

More information

Advanced Java Programming. Swing. Introduction to Swing. Swing libraries. Eran Werner, Tel-Aviv University Summer, 2005

Advanced Java Programming. Swing. Introduction to Swing. Swing libraries. Eran Werner, Tel-Aviv University Summer, 2005 Advanced Java Programming Swing Eran Werner, Tel-Aviv University Summer, 2005 19 May 2005 Advanced Java Programming, Summer 2005 1 Introduction to Swing The Swing package is part of the Java Foundation

More information

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1 Java Swing based on slides by: Walter Milner Java Swing Walter Milner 2005: Slide 1 What is Swing? A group of 14 packages to do with the UI 451 classes as at 1.4 (!) Part of JFC Java Foundation Classes

More information

Swing UI. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff

Swing UI. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff Swing UI by Vlad Costel Ungureanu for Learn Stuff User Interface Command Line Graphical User Interface (GUI) Tactile User Interface (TUI) Multimedia (voice) Intelligent (gesture recognition) 2 Making the

More information

11/6/15. Objec&ves. RouleQe. Assign 8: Understanding Code. Assign 8: Bug. Assignment 8 Ques&ons? PROGRAMMING PARADIGMS

11/6/15. Objec&ves. RouleQe. Assign 8: Understanding Code. Assign 8: Bug. Assignment 8 Ques&ons? PROGRAMMING PARADIGMS Objec&ves RouleQe Assign 8: Refactoring for Extensibility Programming Paradigms Introduc&on to GUIs in Java Ø Event handling Nov 6, 2015 Sprenkle - CSCI209 1 Nov 6, 2015 Sprenkle - CSCI209 2 Assign 8:

More information

Java Swing. Lists Trees Tables Styled Text Components Progress Indicators Component Organizers

Java Swing. Lists Trees Tables Styled Text Components Progress Indicators Component Organizers Course Name: Advanced Java Lecture 19 Topics to be covered Java Swing Lists Trees Tables Styled Text Components Progress Indicators Component Organizers AWT to Swing AWT: Abstract Windowing Toolkit import

More information

Tool Kits, Swing. Overview. SMD158 Interactive Systems Spring Tool Kits in the Abstract. An overview of Swing/AWT

Tool Kits, Swing. Overview. SMD158 Interactive Systems Spring Tool Kits in the Abstract. An overview of Swing/AWT INSTITUTIONEN FÖR Tool Kits, Swing SMD158 Interactive Systems Spring 2005 Jan-28-05 2002-2005 by David A. Carr 1 L Overview Tool kits in the abstract An overview of Swing/AWT Jan-28-05 2002-2005 by David

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

Graphical User Interfaces. Swing. Jose Jesus García Rueda

Graphical User Interfaces. Swing. Jose Jesus García Rueda Graphical User Interfaces. Swing Jose Jesus García Rueda Introduction What are the GUIs? Well known examples Basic concepts Graphical application. Containers. Actions. Events. Graphical elements: Menu

More information

2110: GUIS: Graphical User Interfaces

2110: GUIS: Graphical User Interfaces 2110: GUIS: Graphical User Interfaces Their mouse had a mean time between failure of a week it would jam up irreparably, or... jam up on the table--... It had a flimsy cord whose wires would break. Steve

More information

Chapter 12 Advanced GUIs and Graphics

Chapter 12 Advanced GUIs and Graphics Chapter 12 Advanced GUIs and Graphics Chapter Objectives Learn about applets Explore the class Graphics Learn about the classfont Explore the classcolor Java Programming: From Problem Analysis to Program

More information

KF5008 Program Design & Development. Lecture 1 Usability GUI Design and Implementation

KF5008 Program Design & Development. Lecture 1 Usability GUI Design and Implementation KF5008 Program Design & Development Lecture 1 Usability GUI Design and Implementation Types of Requirements Functional Requirements What the system does or is expected to do Non-functional Requirements

More information

Java Programming Lecture 6

Java Programming Lecture 6 Java Programming Lecture 6 Alice E. Fischer Feb 15, 2013 Java Programming - L6... 1/32 Dialog Boxes Class Derivation The First Swing Programs: Snow and Moving The Second Swing Program: Smile Swing Components

More information

1.00 Lecture 14. Lecture Preview

1.00 Lecture 14. Lecture Preview 1.00 Lecture 14 Introduction to the Swing Toolkit Lecture Preview Over the next 5 lectures, we will introduce you to the techniques necessary to build graphic user interfaces for your applications. Lecture

More information

Dr. Hikmat A. M. AbdelJaber

Dr. Hikmat A. M. AbdelJaber Dr. Hikmat A. M. AbdelJaber JWindow: is a window without a title bar or move controls. The program can move and resize it, but the user cannot. It has no border at all. It optionally has a parent JFrame.

More information

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver Building a GUI in Java with Swing CITS1001 extension notes Rachel Cardell-Oliver Lecture Outline 1. Swing components 2. Building a GUI 3. Animating the GUI 2 Swing A collection of classes of GUI components

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware

More information

Introduction. Introduction

Introduction. Introduction Introduction Many Java application use a graphical user interface or GUI (pronounced gooey ). A GUI is a graphical window or windows that provide interaction with the user. GUI s accept input from: the

More information

Calculator Class. /** * Create a new calculator and show it. */ public Calculator() { engine = new CalcEngine(); gui = new UserInterface(engine); }

Calculator Class. /** * Create a new calculator and show it. */ public Calculator() { engine = new CalcEngine(); gui = new UserInterface(engine); } A Calculator Project This will be our first exposure to building a Graphical User Interface (GUI) in Java The functions of the calculator are self-evident The Calculator class creates a UserInterface Class

More information

BASICS OF GRAPHICAL APPS

BASICS OF GRAPHICAL APPS CSC 2014 Java Bootcamp Lecture 7 GUI Design BASICS OF GRAPHICAL APPS 2 Graphical Applications So far we ve focused on command-line applications, which interact with the user using simple text prompts In

More information

1. Swing Note: Most of the stuff stolen from or from the jdk documentation. Most programs are modified or written by me. This section explains the

1. Swing Note: Most of the stuff stolen from or from the jdk documentation. Most programs are modified or written by me. This section explains the 1. Swing Note: Most of the stuff stolen from or from the jdk documentation. Most programs are modified or written by me. This section explains the various elements of the graphical user interface, i.e.,

More information

encompass a group of features for building Graphical User Interfaces (GUI).

encompass a group of features for building Graphical User Interfaces (GUI). Java GUI (intro) JFC Java Foundation Classes encompass a group of features for building Graphical User Interfaces (GUI). javax.swing.* used for building GUIs. Some basic functionality is already there

More information

Class 14: Introduction to the Swing Toolkit

Class 14: Introduction to the Swing Toolkit Introduction to Computation and Problem Solving Class 14: Introduction to the Swing Toolkit Prof. Steven R. Lerman and Dr. V. Judson Harward 1 Class Preview Over the next 5 lectures, we will introduce

More information

The Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC).

The Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC). The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness The Abstract Windowing Toolkit (AWT) was part of the JDK form the beginning,

More information

Swing from A to Z Some Simple Components. Preface

Swing from A to Z Some Simple Components. Preface By Richard G. Baldwin baldwin.richard@iname.com Java Programming, Lecture Notes # 1005 July 31, 2000 Swing from A to Z Some Simple Components Preface Introduction Sample Program Interesting Code Fragments

More information

Basicsof. JavaGUI and SWING

Basicsof. JavaGUI and SWING Basicsof programming3 JavaGUI and SWING GUI basics Basics of programming 3 BME IIT, Goldschmidt Balázs 2 GUI basics Mostly window-based applications Typically based on widgets small parts (buttons, scrollbars,

More information

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo Widgets Overview Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo Widget Widget is a generic name for parts of an interface that have their own behavior: buttons, progress

More information

Part I: Learn Common Graphics Components

Part I: Learn Common Graphics Components OOP GUI Components and Event Handling Page 1 Objectives 1. Practice creating and using graphical components. 2. Practice adding Event Listeners to handle the events and do something. 3. Learn how to connect

More information

The AWT Package, An Overview

The AWT Package, An Overview Richard G Baldwin (512) 223-4758, baldwin@austin.cc.tx.us, http://www2.austin.cc.tx.us/baldwin/ The AWT Package, An Overview Java Programming, Lecture Notes # 110, Revised 02/21/98. Preface Introduction

More information

Chapter 12 GUI Basics

Chapter 12 GUI Basics Chapter 12 GUI Basics 1 Creating GUI Objects // Create a button with text OK JButton jbtok = new JButton("OK"); // Create a label with text "Enter your name: " JLabel jlblname = new JLabel("Enter your

More information

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Graphics. Lecture 18 COP 3252 Summer June 6, 2017 Graphics Lecture 18 COP 3252 Summer 2017 June 6, 2017 Graphics classes In the original version of Java, graphics components were in the AWT library (Abstract Windows Toolkit) Was okay for developing simple

More information

CS11 Java. Fall Lecture 3

CS11 Java. Fall Lecture 3 CS11 Java Fall 2014-2015 Lecture 3 Today s Topics! Class inheritance! Abstract classes! Polymorphism! Introduction to Swing API and event-handling! Nested and inner classes Class Inheritance! A third of

More information

Java IDE Programming-I

Java IDE Programming-I Java IDE Programming-I Graphical User Interface : is an interface that uses pictures and other graphic entities along with text, to interact with user. User can interact with GUI using mouse click/ or

More information

Chapter 6: Graphical User Interfaces

Chapter 6: Graphical User Interfaces Chapter 6: Graphical User Interfaces CS 121 Department of Computer Science College of Engineering Boise State University April 21, 2015 Chapter 6: Graphical User Interfaces CS 121 1 / 36 Chapter 6 Topics

More information

Review. Designing Interactive Systems II. Introduction. Web 2.0 in keywords GWT Cappuccino HTML5. Cross platform GUI Toolkit

Review. Designing Interactive Systems II. Introduction. Web 2.0 in keywords GWT Cappuccino HTML5. Cross platform GUI Toolkit Review Designing Interactive Systems II Computer Science Graduate Programme SS 2010 Prof. Dr. RWTH Aachen University Web 2.0 in keywords GWT Cappuccino HTML5 http://hci.rwth-aachen.de 1 2 Introduction

More information

Designing Interactive Systems II

Designing Interactive Systems II Designing Interactive Systems II Computer Science Graduate Programme SS 2010 Prof. Dr. RWTH Aachen University http://hci.rwth-aachen.de 1 Review 2 Review Web 2.0 in keywords 2 Review Web 2.0 in keywords

More information

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1 Datenbank-Praktikum Universität zu Lübeck Sommersemester 2006 Lecture: Swing Ho Ngoc Duc 1 Learning objectives GUI applications Font, Color, Image Running Applets as applications Swing Components q q Text

More information

Unit 6: Graphical User Interface

Unit 6: Graphical User Interface Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Unit 6: Graphical User Interface 1 1. Overview of the

More information

Containers and Components

Containers and Components Containers and Components container A GUI has many components in containers. A container contains other components. A container is also a component; so a container may contain other containers. component

More information

Chapter 13 GUI Basics. Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved.

Chapter 13 GUI Basics. Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved. Chapter 13 GUI Basics 1 Motivations The design of the API for Java GUI programming is an excellent example of how the object-oriented principle is applied. In the chapters that follow, you will learn the

More information

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User CSE3461 Control Flow Paradigms: Reacting to the User Control Flow: Overview Definition of control flow: The sequence of execution of instructions in a program. Control flow is determined at run time by

More information

GUI and its COmponent Textfield, Button & Label. By Iqtidar Ali

GUI and its COmponent Textfield, Button & Label. By Iqtidar Ali GUI and its COmponent Textfield, Button & Label By Iqtidar Ali GUI (Graphical User Interface) GUI is a visual interface to a program. GUI are built from GUI components. A GUI component is an object with

More information

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Rui Moreira Some useful links: http://java.sun.com/docs/books/tutorial/uiswing/toc.html http://www.unix.org.ua/orelly/java-ent/jfc/

More information

Widget. Widget is a generic name for parts of an interface that have their own behaviour. e.g., buttons, progress bars, sliders, drop-down

Widget. Widget is a generic name for parts of an interface that have their own behaviour. e.g., buttons, progress bars, sliders, drop-down Widgets Jeff Avery Widget Widget is a generic name for parts of an interface that have their own behaviour. e.g., buttons, progress bars, sliders, drop-down menus, spinners, file dialog boxes, etc are

More information

Graphical User Interfaces

Graphical User Interfaces Graphical User Interfaces Java Programming (Languages in Depth Series) Christoph Angerer April 26th 2007 Why Java UI Programming is Special Platform independence ( write once runs anywhere ): Windows,

More information

Graphical interfaces & event-driven programming

Graphical interfaces & event-driven programming Graphical interfaces & event-driven programming Lecture 12 of TDA 540 (Objektorienterad Programmering) Carlo A. Furia Alex Gerdes Chalmers University of Technology Gothenburg University Fall 2017 Pop quiz!

More information

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright GUI Basics Object Orientated Programming in Java Benjamin Kenwright Outline Essential Graphical User Interface (GUI) Concepts Libraries, Implementation, Mechanics,.. Abstract Windowing Toolkit (AWT) Java

More information

User interfaces and Swing

User interfaces and Swing User interfaces and Swing Overview, applets, drawing, action listening, layout managers. APIs: java.awt.*, javax.swing.*, classes names start with a J. Java Lectures 1 2 Applets public class Simple extends

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 10(b): Working with Controls Agenda 2 Case study: TextFields and Labels Combo Boxes buttons List manipulation Radio buttons and checkboxes

More information

GUI Programming. Chapter. A Fresh Graduate s Guide to Software Development Tools and Technologies

GUI Programming. Chapter. A Fresh Graduate s Guide to Software Development Tools and Technologies A Fresh Graduate s Guide to Software Development Tools and Technologies Chapter 12 GUI Programming CHAPTER AUTHORS Ang Ming You Ching Sieh Yuan Francis Tam Pua Xuan Zhan Software Development Tools and

More information

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming Objectives: Last revised March 2, 2017 1. To introduce the notion of a component and some basic Swing components (JLabel, JTextField,

More information

Chapter 8. Java continued. CS Hugh Anderson s notes. Page number: 264 ALERT. MCQ test next week. This time. This place.

Chapter 8. Java continued. CS Hugh Anderson s notes. Page number: 264 ALERT. MCQ test next week. This time. This place. Chapter 8 Java continued CS3283 - Hugh Anderson s notes. Page number: 263 ALERT MCQ test next week This time This place Closed book CS3283 - Hugh Anderson s notes. Page number: 264 ALERT Assignment #2

More information

Java continued. Chapter 8 ALERT ALERT. Last week. MCQ test next week. This time. This place. Closed book. Assignment #2 is for groups of 3

Java continued. Chapter 8 ALERT ALERT. Last week. MCQ test next week. This time. This place. Closed book. Assignment #2 is for groups of 3 Chapter 8 Java continued MCQ test next week This time This place Closed book ALERT CS3283 - Hugh Anderson s notes. Page number: 263 CS3283 - Hugh Anderson s notes. Page number: 264 ALERT Last week Assignment

More information

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords Goals By the end of this lesson, you should: Lecture 7 More GUI programming 1. Be able to write Java s with JTextField, JList, JCheckBox and JRadioButton components 2. Be able to implement a ButtonGroup

More information

Systems Programming Graphical User Interfaces

Systems Programming Graphical User Interfaces Systems Programming Graphical User Interfaces Julio Villena Román (LECTURER) CONTENTS ARE MOSTLY BASED ON THE WORK BY: José Jesús García Rueda Systems Programming GUIs based on Java

More information

Lecture 9. Lecture

Lecture 9. Lecture Layout Components MVC Design PaCern GUI Programming Observer Design PaCern D0010E Lecture 8 - Håkan Jonsson 1 Lecture 8 - Håkan Jonsson 2 Lecture 8 - Håkan Jonsson 3 1 1. GUI programming In the beginning,

More information

Swing from A to Z Using Focus in Swing, Part 2. Preface

Swing from A to Z Using Focus in Swing, Part 2. Preface Swing from A to Z Using Focus in Swing, Part 2 By Richard G. Baldwin Java Programming, Lecture Notes # 1042 November 27, 2000 Preface Introduction Sample Program Interesting Code Fragments Summary What's

More information

(Incomplete) History of GUIs

(Incomplete) History of GUIs CMSC 433 Programming Language Technologies and Paradigms Spring 2004 Graphical User Interfaces April 20, 2004 (Incomplete) History of GUIs 1973: Xerox Alto 3-button mouse, bit-mapped display, windows 1981:

More information

JRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();

JRadioButton account_type_radio_button2 = new JRadioButton(Current); ButtonGroup account_type_button_group = new ButtonGroup(); Q)Write a program to design an interface containing fields User ID, Password and Account type, and buttons login, cancel, edit by mixing border layout and flow layout. Add events handling to the button

More information

Building Java Programs Bonus Slides

Building Java Programs Bonus Slides Building Java Programs Bonus Slides Graphical User Interfaces Copyright (c) Pearson 2013. All rights reserved. Graphical input and output with JOptionPane JOptionPane An option pane is a simple dialog

More information

Widgets. Widgets Widget Toolkits. 2.3 Widgets 1

Widgets. Widgets Widget Toolkits. 2.3 Widgets 1 Widgets Widgets Widget Toolkits 2.3 Widgets 1 User Interface Widget Widget is a generic name for parts of an interface that have their own behavior: buttons, drop-down menus, spinners, file dialog boxes,

More information

Chapter 12 GUI Basics. Motivations. The design of the API for Java GUI programming

Chapter 12 GUI Basics. Motivations. The design of the API for Java GUI programming Chapter 12 GUI Basics 1 Motivations The design of the API for Java GUI programming is an excellent example of how the object-orientedoriented principle is applied. In the chapters that follow, you will

More information

Graphical User Interfaces

Graphical User Interfaces Graphical User Interfaces CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Overview Command line versus GUI apps

More information

Resizing a Window. COSC 3461: Module 5B. What is Widget Layout? Size State Transitions. What is Widget Layout? Hierarchical Widget Layout.

Resizing a Window. COSC 3461: Module 5B. What is Widget Layout? Size State Transitions. What is Widget Layout? Hierarchical Widget Layout. COSC 3461: Module 5B Resizing a Window Widgets II What has changed? scrollbar added menu has wrapped toolbar modified (buttons lost) 2 What is Widget Layout? Size State Transitions Recall: each widget

More information