Object-Oriented Programming Design. Topic : User Interface Components with Swing GUI Part III

Size: px
Start display at page:

Download "Object-Oriented Programming Design. Topic : User Interface Components with Swing GUI Part III"

Transcription

1 Electrical and Computer Engineering Object-Oriented Topic : User Interface Components with Swing GUI Part III Maj Joel Young Joel.Young@afit.edu 17-Sep-03 Maj Joel Young

2 Creating GUI Apps The Process Overview Step 1. Create a JFrame Step 2. Create JPanel(s) to hold controls Step 3. Add JPanel(s) to JFrame s content pane, and put JPanels within other JPanels as needed Step 4. Create Controls Step 5. Add Controls to JPanel(s) Step 6. Create event listeners, add to components Title Here Label: Ok Text Field Cancel // The Listener class MyActionListener implements ActionListener public void actionperformed( ActionEvent e) JOptionPane.showMessageDialog( null, "Button clicked!"); 2

3 Layout Managers - Basics Positioning controls/panels is not a trivial task What if the user resizes the window? What if the resolution of the screen is changed? What if the application is run on two different operating system environments? (Win 2000, Solaris) Layout Managers help to keep our interfaces organized even if the above changes do occur A layout manager sets the policy for how an interface s components will be ordered, stacked, and packed 3

4 Layout Managers - Basics There are many kinds of layout managers: Border Layout (simple): Organizes display into North, South, East, West, and Center regions Flow Layout (simple): Organizes display by simply creating rows of components, where a new row is created when horizontal space runs out Grid Layout (medium): Organizes display into an evenly divided grid, where each component gets one cell Box Layout (medium): Organizes display into a column or row of boxes, the size of which can be specified Gridbag Layout (complex): Organizes display into a grid, but components may take multiple cells, and cells are not of uniform size Null Layout: No layout management, components are placed at specific X,Y coordinates and never move or resize 4

5 Border Layout public class TestFrame5 extends JFrame public TestFrame5() // Create a JPanel with a border layout JPanel p = new JPanel(new BorderLayout()); // Add labels p.add(new JButton("North"),BorderLayout.NORTH); p.add(new JButton("South"),BorderLayout.SOUTH); p.add(new JButton("East"),BorderLayout.EAST); p.add(new JButton("West"),BorderLayout.WEST); p.add(new JButton("Center"),BorderLayout.CENTER); // Add panel to content pane this.getcontentpane().add(p); TestFrame5 testframe = new TestFrame5(); testframe.setsize(300,300); testframe.show(); 5

6 FlowLayout public class TestFrame6 extends JFrame public TestFrame6() // Create a JPanel with a flow layout - centering items JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER)); // Add labels p.add(new JButton("First")); p.add(new JButton("Second")); p.add(new JButton("Third")); p.add(new JButton("Fourth")); p.add(new JButton("Fifth")); // Add panel to content pane this.getcontentpane().add(p); TestFrame6 testframe = new TestFrame6(); testframe.setsize(300,300); testframe.show(); 6

7 Grid Layout public class TestFrame7 extends JFrame public TestFrame7() // Create a JPanel with a grid layout JPanel p = new JPanel(new GridLayout(3,2)); // Add labels p.add(new JButton("Row 1, Col 1")); p.add(new JButton("Row 1, Col 2")); p.add(new JButton("Row 2, Col 1")); p.add(new JButton("Row 2, Col 2")); p.add(new JButton("Row 3, Col 1")); // Add panel to content pane this.getcontentpane().add(p); TestFrame7 testframe = new TestFrame7(); testframe.setsize(300,300); testframe.show(); 7

8 Buttons Plain Vanilla Buttons (JButton) Clicking causes an action to occur (fires ActionEvent) Can have a text label, icon, or both Checkbox Buttons (JCheckBox) A toggle button click to turn on state Application can examine to see if button selected or not Radio Buttons (JRadioButton) A toggle button but buttons are arranged in groups, and only one button can be active Application can examine which is active 8

9 Button Example public class ButtonTest1 extends JFrame public ButtonTest1() // Create a JPanel with a box layout JPanel p = new JPanel(); p.setlayout(new BoxLayout(p,BoxLayout.Y_AXIS)); // Add buttons JButton tb = new JButton("Text Button"); tb.setalignmentx(component.center_alignment); p.add(tb); JButton ib = new JButton(new ImageIcon("icons/Help24.gif")); ib.setalignmentx(component.center_alignment); p.add(ib); this.getcontentpane().add(p); ButtonTest1 testframe = new ButtonTest1(); testframe.setsize(300,300); testframe.show(); 9

10 CheckBox Button Example public class ButtonTest2 extends JFrame implements ActionListener JCheckBox cbred = new JCheckBox("Red"); JCheckBox cbgreen = new JCheckBox("Green"); JCheckBox cbblue = new JCheckBox("Blue"); JLabel sellabel = new JLabel("Selected: (none)"); public ButtonTest2() // Create a JPanel with a box layout JPanel p = new JPanel(); p.setlayout( new BoxLayout(p,BoxLayout.Y_AXIS)); // Add buttons cbred.addactionlistener(this); p.add(cbred); cbgreen.addactionlistener(this); p.add(cbgreen); cbblue.addactionlistener(this); p.add(cbblue); p.add(box.createrigidarea( new Dimension(0,20))); p.add(sellabel); // Add panel to content pane this.getcontentpane().add(p); public void actionperformed(actionevent e) String label = "Selected: "; if (cbred.isselected()) label += "Red "; if (cbgreen.isselected()) label += "Green "; if (cbblue.isselected()) label += "Blue"; sellabel.settext(label); ButtonTest2 testframe = new ButtonTest2(); testframe.setsize(300,300); testframe.show(); 10

11 Labels (JLabel) Usually displays a line of text to explain something on the display (like a prompt next to a text field) Can also be an image, or an image with text Label does not get keyboard focus, does not issue labelspecific events Can be dynamically changed by the application (useful for counters or status fields) 11

12 Label Example public class LabelTest1 extends JFrame public LabelTest1() // Create a JPanel with a box layout JPanel p = new JPanel(); p.setlayout(new BoxLayout(p,BoxLayout.X_AXIS)); // Add controls p.add(box.createhorizontalglue()); JLabel lb = new JLabel("Click this button to explode:"); lb.setalignmenty(component.center_alignment); p.add(lb); p.add(box.createrigidarea(new Dimension(5,0))); JButton tb = new JButton("Self-Destruct"); tb.setalignmenty(component.center_alignment); p.add(tb); p.add(box.createhorizontalglue()); // Add panel to content pane this.getcontentpane().add(p); LabelTest1 testframe = new LabelTest1(); testframe.setsize(300,300); testframe.show(); 12

13 Dynamic Label Example public class LabelTest1 extends JFrame int counter = 0; JLabel hitlabel; public LabelTest1() // Create a JPanel with a box layout JPanel p1 = new JPanel(); p1.setlayout(new BoxLayout(p1,BoxLayout.X_AXIS)); // Add controls p1.add(box.createhorizontalglue()); JLabel lb = new JLabel("Click this button to explode:"); lb.setalignmenty(component.center_alignment); p1.add(lb); p1.add(box.createrigidarea(new Dimension(5,0))); JButton tb = new JButton("Self-Destruct"); tb.setalignmenty(component.center_alignment); tb.addactionlistener(new ActionListener() public void actionperformed(actionevent e) hitlabel.settext(string.valueof(++counter)); ); p1.add(tb); p1.add(box.createhorizontalglue()); JPanel p2 = new JPanel(); p2.setlayout(new FlowLayout(FlowLayout.CENTER)); hitlabel = new JLabel(""); p2.add(hitlabel); LabelTest1 testframe = new LabelTest1(); testframe.setsize(300,300); testframe.show(); // Add panel to content pane this.getcontentpane().setlayout(new BorderLayout()); this.getcontentpane().add(p1,borderlayout.center); this.getcontentpane().add(p2,borderlayout.south); 13

14 Text Handling Text Fields (JTextField) Used to input small amounts of text (usually single fields, like names or addresses) Text Editors (JTextEditor, JTextPane) Essentially small word processors that can be embedded in your GUI Text Areas (JTextArea) Simplified text editing controls 14

15 Text Field Example public class TextFieldTest1 extends JFrame JTextField usertext; public TextFieldTest1() // Create a JPanel with a box layout JPanel p1 = new JPanel(); p1.setlayout(new BoxLayout(p1,BoxLayout.X_AXIS)); // Create a label for a prompt JLabel prompt = new JLabel("Enter Name:"); p1.add(prompt); // Create text field usertext = new JTextField(); usertext.setmaximumsize(new Dimension(150,20)); usertext.addactionlistener(new ActionListener() public void actionperformed(actionevent e) JOptionPane.showMessageDialog(null, "You typed:"+usertext.gettext()); ); p1.add(usertext); this.getcontentpane().add(p1); TextFieldTest1 testframe = new TextFieldTest1(); testframe.setsize(300,300); testframe.show(); 15

16 JTextPane/JTextEditor Example public class TextFieldTest2 extends JFrame JTextPane tp = new JTextPane(); JEditorPane ep = new JEditorPane("text/html",""); public TextFieldTest2() // Create a JPanel with a box layout JPanel p1 = new JPanel(); p1.setlayout(new GridLayout(1,2)); // Create a ScrollPane for the TextPane JScrollPane sp = new JScrollPane(tp); p1.add(sp); sp = new JScrollPane(ep); p1.add(sp); ep.seteditable(false); // Add a button to transfer text JPanel p2 = new JPanel( new FlowLayout(FlowLayout.CENTER)); JButton copy = new JButton("Copy"); copy.addactionlistener(new ActionListener() public void actionperformed(actionevent e) ep.settext(tp.gettext()); ); p2.add(copy); this.getcontentpane().setlayout(new BorderLayout()); this.getcontentpane().add(p1,borderlayout.center); this.getcontentpane().add(p2,borderlayout.south); TextFieldTest2 testframe = new TextFieldTest2(); testframe.pack(); testframe.show(); 16

17 Borders All JComponents allow you to specify a border Types of Borders Line borders Etched borders Beveled borders Title borders 17

18 JTextPane/JTextEditor Example public class TextFieldTest2 extends JFrame JTextPane tp = new JTextPane(); JEditorPane ep = new JEditorPane("text/html",""); public TextFieldTest2() // Create Borders Border etch = BorderFactory.createEtchedBorder(); // Create a JPanel with a box layout JPanel p1 = new JPanel(); p1.setlayout(new GridLayout(1,2)); // Create a ScrollPane for the TextPane JScrollPane sp = new JScrollPane(tp); sp.setborder( BorderFactory.createTitledBorder(etch,"Text Pane")); p1.add(sp); sp = new JScrollPane(ep); sp.setborder( BorderFactory.createTitledBorder(etch,"Editor Pane")); p1.add(sp); ep.seteditable(false); // Add a button to transfer text JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton copy = new JButton("Copy"); copy.addactionlistener(new ActionListener() public void actionperformed(actionevent e) ep.settext(tp.gettext()); ); p2.setborder(etch); p2.add(copy); this.getcontentpane().setlayout(new BorderLayout()); this.getcontentpane().add(p1,borderlayout.center); this.getcontentpane().add(p2,borderlayout.south); TextFieldTest2 testframe = new TextFieldTest2(); testframe.pack(); testframe.show(); 18

19 Lists Plain Lists (JList) Just show a list of items Single or multiple select Scrollable Drop-Down Lists (JComboBox) Show a list of options you can pick from Can t be altered by user Combo Lists (JComboBox) Same as drop-down, but allows users to edit entries 19

20 JList Example public class TestList1 extends JFrame implements ActionListener private JList list; private DefaultListModel model; private JTextField text; public TestList1() // Create model, populate with data model = new DefaultListModel(); model.addelement("csce 694"); model.addelement("csce 646"); model.addelement("csce 593"); model.addelement("eeng 653"); // Create list, specify data model list = new JList(model); JScrollPane sp = new JScrollPane(list); // Create a JPanel with a box layout JPanel p = new JPanel(); p.setlayout(new BoxLayout(p,BoxLayout.X_AXIS)); text = new JTextField(); text.setminimumsize(new Dimension(150,5)); p.add(text); JButton b = new JButton("Add Class"); b.addactionlistener(this); p.add(b); // Add panel to content pane this.getcontentpane().setlayout(new BorderLayout()); this.getcontentpane().add(p,borderlayout.south); this.getcontentpane().add(sp,borderlayout.center); public void actionperformed(actionevent e) model.addelement(text.gettext()); text.settext(""); TestList1 testframe = new TestList1(); testframe.setsize(300,300); testframe.show(); 20

21 JList Example with Selection Listener public class TestList2 extends JFrame implements ListSelectionListener private JList list; private DefaultListModel model; private JLabel text; public TestList2() // Create model, populate with data model = new DefaultListModel(); model.addelement("csce 694"); model.addelement("csce 646"); model.addelement("csce 593"); model.addelement("eeng 653"); // Create list, specify data model list = new JList(model); list.addlistselectionlistener(this); JScrollPane sp = new JScrollPane(list); // Create a JPanel with a flow layout JPanel p = new JPanel(new FlowLayout()); text = new JLabel("(Nothing selected)"); p.add(text); public void valuechanged(listselectionevent e) String item = (String) list.getselectedvalue(); text.settext(item); TestList2 testframe = new TestList2(); testframe.setsize(300,300); testframe.show(); // Add panel to content pane this.getcontentpane().setlayout(new BorderLayout()); this.getcontentpane().add(p,borderlayout.south); this.getcontentpane().add(sp,borderlayout.center); 21

22 JComboBox Example Not Editable public class TestList3 extends JFrame implements ActionListener private JComboBox list; private JLabel text; public TestList3() text = new JLabel("(Nothing selected)"); // Create combo box list = new JComboBox(); list.additem("csce431"); list.additem("csce492"); list.additem("csce486"); list.additem("csce531"); list.additem("csce586"); list.additem("csce593"); list.additem("csce646"); // Scroll after four entries list.setmaximumrowcount(4); // Respond to selections list.addactionlistener(this); // Create a JPanel with a flow layout JPanel p = new JPanel(new FlowLayout()); p.add(text); public void actionperformed(actionevent e) String item = (String) list.getselecteditem(); text.settext("registered for: "+item); TestList3 testframe = new TestList3(); testframe.setsize(300,300); testframe.show(); // Add panel to content pane this.getcontentpane().setlayout(new BorderLayout()); this.getcontentpane().add(p,borderlayout.south); this.getcontentpane().add(new JLabel(" "),BorderLayout.CENTER); this.getcontentpane().add(list,borderlayout.north); 22

23 JComboBox Example -- Editable public class TestList4 extends JFrame implements ActionListener private JComboBox list; private JLabel text; public TestList4() text = new JLabel("(Nothing selected)"); // Create combo box list = new JComboBox(); list.additem("csce431"); list.additem("csce492"); list.additem("csce486"); list.additem("csce531"); list.additem("csce586"); list.additem("csce593"); list.additem("csce646"); // Make editable list.seteditable(true); // Scroll after four entries list.setmaximumrowcount(4); // Respond to selections list.addactionlistener(this); // Create a JPanel with a flow layout JPanel p = new JPanel(new FlowLayout()); p.add(text); // Add panel to content pane this.getcontentpane().setlayout(new BorderLayout()); this.getcontentpane().add(p,borderlayout.south); this.getcontentpane().add(new JLabel(" "),BorderLayout.CENTER); this.getcontentpane().add(list,borderlayout.north); public void actionperformed(actionevent e) String item = (String) list.getselecteditem(); text.settext("registered for: "+item); TestList4 testframe = new TestList4(); testframe.setsize(300,300); testframe.show(); 23

24 Menus Menus (JMenu) Top-level menu items, do not cause action to occur Containers for JMenuItems and other JMenus Menu Items (JMenuItem) Bottom-level menu items, selecting causes an action Menu Bars (JMenuBar) Container for menus, are placed in the JFrame 24

25 Menu Example // Modified example from The Java Tutorial public class TestMenu1 extends JFrame implements ActionListener JTextArea output; public TestMenu1() JMenuBar menubar; JMenu menu, submenu; JMenuItem menuitem; JRadioButtonMenuItem rbmenuitem; JCheckBoxMenuItem cbmenuitem; //Add regular components to the window Container contentpane = getcontentpane(); output = new JTextArea(5, 30); output.seteditable(false); contentpane.add(new JScrollPane(output), BorderLayout.CENTER); //Create the menu bar. menubar = new JMenuBar(); setjmenubar(menubar); //Build the first menu. menu = new JMenu("A Menu"); menubar.add(menu); //a group of JMenuItems menuitem = new JMenuItem("A menu item", KeyEvent.VK_T); menuitem.addactionlistener(this); menu.add(menuitem); menuitem = new JMenuItem("Another menu item",keyevent.vk_b); menuitem.addactionlistener(this); menu.add(menuitem); 25

26 Menu Example -- Continued //a group of radio button menu items menu.addseparator(); ButtonGroup group = new ButtonGroup(); rbmenuitem = new JRadioButtonMenuItem( "A radio button menu item"); rbmenuitem.setselected(true); group.add(rbmenuitem); rbmenuitem.addactionlistener(this); menu.add(rbmenuitem); rbmenuitem = new JRadioButtonMenuItem( "Another one"); group.add(rbmenuitem); rbmenuitem.addactionlistener(this); menu.add(rbmenuitem); //a group of check box menu items menu.addseparator(); cbmenuitem = new JCheckBoxMenuItem( "A check box menu item"); cbmenuitem.addactionlistener(this); menu.add(cbmenuitem); cbmenuitem = new JCheckBoxMenuItem( "Another one"); cbmenuitem.addactionlistener(this); menu.add(cbmenuitem); //a submenu menu.addseparator(); submenu = new JMenu("A submenu"); menuitem = new JMenuItem( "An item in the submenu"); menuitem.addactionlistener(this); submenu.add(menuitem); menuitem = new JMenuItem("Another item"); menuitem.addactionlistener(this); submenu.add(menuitem); menu.add(submenu); //Build second menu in the menu bar. menu = new JMenu("Another Menu"); menubar.add(menu); public void actionperformed(actionevent e) JMenuItem source = (JMenuItem)(e.getSource()); String s = "Item clicked: "+source.gettext()+"\n"; output.append(s); TestMenu1 window = new TestMenu1(); window.setsize(450, 260); window.setvisible(true); 26

27 Approach to building a user interface the interface (pen and paper, or visual toolkit) Convert design to code Make the components in the interface look the way you want them to Position user interface components where you want them Handle user input (respond to events generated by user interface components) In Java Create the component with the appropriate constructor parameters Add a flow layout manager to container Add individual components to container Add appropriate event handlers (listener interfaces) 27

28 Homework Code the basic GUI window for your tabulation mode display, buttons, operations, =, clear No functionality required, not even for number buttons to cause text to appear in the display REMEMBER! Draw it on paper. Use containers to group things (maybe a grid for the numbers beside a grid for the operations, with a display on top). Amazed at how easy it is? 28

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

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

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

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

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 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

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

Agenda. Container and Component

Agenda. Container and Component Agenda Types of GUI classes/objects Step-by-step guide to create a graphic user interface Step-by-step guide to event-handling PS5 Problem 1 PS5 Problem 2 Container and Component There are two types of

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

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

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

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

JAVA NOTES GRAPHICAL USER INTERFACES

JAVA NOTES GRAPHICAL USER INTERFACES 1 JAVA NOTES GRAPHICAL USER INTERFACES Terry Marris 24 June 2001 5 TEXT AREAS 5.1 LEARNING OUTCOMES By the end of this lesson the student should be able to understand how to get multi-line input from the

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

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

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

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

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

Parts of a Contract. Contract Example. Interface as a Contract. Wednesday, January 30, 13. Postcondition. Preconditions.

Parts of a Contract. Contract Example. Interface as a Contract. Wednesday, January 30, 13. Postcondition. Preconditions. Parts of a Contract Syntax - Method signature Method name Parameter list Return type Semantics - Comments Preconditions: requirements placed on the caller Postconditions: what the method modifies and/or

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

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

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

1.1 GUI. JFrame. import java.awt.*; import javax.swing.*; public class XXX extends JFrame { public XXX() { // XXX. init() main() public static

1.1 GUI. JFrame. import java.awt.*; import javax.swing.*; public class XXX extends JFrame { public XXX() { // XXX. init() main() public static 18 7 17 1 1.1 GUI ( ) GUI ( ) JFrame public class XXX extends JFrame { public XXX() { // XXX // init()... // ( )... init() main() public static public class XXX extends JFrame { public XXX() { // setsize(,

More information

JAVA NOTES GRAPHICAL USER INTERFACES

JAVA NOTES GRAPHICAL USER INTERFACES 1 JAVA NOTES GRAPHICAL USER INTERFACES Terry Marris July 2001 8 DROP-DOWN LISTS 8.1 LEARNING OUTCOMES By the end of this lesson the student should be able to understand and use JLists understand and use

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

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

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

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

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

TTTK Program Design and Problem Solving Tutorial 3 (GUI & Event Handlings)

TTTK Program Design and Problem Solving Tutorial 3 (GUI & Event Handlings) TTTK1143 - Program Design and Problem Solving Tutorial 3 (GUI & Event Handlings) Topic: JApplet and ContentPane. 1. Complete the following class to create a Java Applet whose pane s background color is

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

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp DM550 / DM857 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/dm550/ http://imada.sdu.dk/~petersk/dm857/ GRAPHICAL USER INTERFACES 2 HelloWorld Reloaded

More information

CSE Lab 8 Assignment Note: This is the last lab for CSE 1341

CSE Lab 8 Assignment Note: This is the last lab for CSE 1341 CSE 1341 - Lab 8 Assignment Note: This is the last lab for CSE 1341 Pre-Lab : There is no pre-lab this week. Lab (100 points) The objective of Lab 8 is to get familiar with and utilize the wealth of Java

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

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

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 1/15/10 1. To introduce the notion of a component and some basic Swing components (JLabel, JTextField, JTextArea,

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

Window Interfaces Using Swing. Chapter 12

Window Interfaces Using Swing. Chapter 12 Window Interfaces Using Swing 1 Reminders Project 7 due Nov 17 @ 10:30 pm Project 6 grades released: regrades due by next Friday (11-18-2005) at midnight 2 GUIs - Graphical User Interfaces Windowing systems

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

Java Swing. Recitation 11/(20,21)/2008. CS 180 Department of Computer Science, Purdue University

Java Swing. Recitation 11/(20,21)/2008. CS 180 Department of Computer Science, Purdue University Java Swing Recitation 11/(20,21)/2008 CS 180 Department of Computer Science, Purdue University Announcements Project 8 is out Milestone due on Dec 3rd, 10:00 pm Final due on Dec 10th, 10:00 pm No classes,

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

Graphical User Interfaces in Java - SWING

Graphical User Interfaces in Java - SWING Graphical User Interfaces in Java - SWING Graphical User Interfaces (GUI) Each graphical component that the user can see on the screen corresponds to an object of a class Component: Window Button Menu...

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

12/22/11. Copyright by Pearson Education, Inc. All Rights Reserved.

12/22/11. Copyright by Pearson Education, Inc. All Rights Reserved. } Radio buttons (declared with class JRadioButton) are similar to checkboxes in that they have two states selected and not selected (also called deselected). } Radio buttons normally appear as a group

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

GUI Components Continued EECS 448

GUI Components Continued EECS 448 GUI Components Continued EECS 448 Lab Assignment In this lab you will create a simple text editor application in order to learn new GUI design concepts This text editor will be able to load and save text

More information

Today. cisc3120-fall2012-parsons-lectiii.3 2

Today. cisc3120-fall2012-parsons-lectiii.3 2 MORE GUI COMPONENTS Today Last time we looked at some of the components that the: AWT Swing libraries provide for building GUIs in Java. This time we will look at several more GUI component topics. We

More information

CompSci 125 Lecture 17. GUI: Graphics, Check Boxes, Radio Buttons

CompSci 125 Lecture 17. GUI: Graphics, Check Boxes, Radio Buttons CompSci 125 Lecture 17 GUI: Graphics, Check Boxes, Radio Buttons Announcements GUI Review Review: Inheritance Subclass is a Parent class Includes parent s features May Extend May Modify extends! Parent

More information

CSE 1325 Project Description

CSE 1325 Project Description CSE 1325 Summer 2016 Object-Oriented and Event-driven Programming (Using Java) Instructor: Soumyava Das Graphical User Interface (GUI), Event Listeners and Handlers Project IV Assigned On: 07/28/2016 Due

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

Chapter 7: A First Look at GUI Applications

Chapter 7: A First Look at GUI Applications Chapter 7: A First Look at GUI Applications Starting Out with Java: From Control Structures through Objects Fourth Edition by Tony Gaddis Addison Wesley is an imprint of 2010 Pearson Addison-Wesley. All

More information

Lecture 6: Components. CS480: Graphical User Interfaces. Dario Salvucci, Drexel University.

Lecture 6: Components. CS480: Graphical User Interfaces. Dario Salvucci, Drexel University. Lecture 6: Components CS480: Graphical User Interfaces. Dario Salvucci, Drexel University. 1 Widget Week! Look at the most common GUI components see what they do see how they work High-level goal: Get

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

Programming graphics

Programming graphics Programming graphics Need a window javax.swing.jframe Several essential steps to use (necessary plumbing ): Set the size width and height in pixels Set a title (optional), and a close operation Make it

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

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

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

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

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

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

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

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

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

Prototyping a Swing Interface with the Netbeans IDE GUI Editor

Prototyping a Swing Interface with the Netbeans IDE GUI Editor Prototyping a Swing Interface with the Netbeans IDE GUI Editor Netbeans provides an environment for creating Java applications including a module for GUI design. Here we assume that we have some existing

More information

Swing Programming Example Number 2

Swing Programming Example Number 2 1 Swing Programming Example Number 2 Problem Statement (Part 1 and 2 (H/w- assignment) 2 Demonstrate the use of swing Label, TextField, RadioButton, CheckBox, Listbox,Combo Box, Toggle button,image Icon

More information

Chapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus

Chapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus Chapter 13 Lab Advanced GUI Applications Lab Objectives Be able to add a menu to the menu bar Be able to use nested menus Be able to add scroll bars, giving the user the option of when they will be seen.

More information

Object Oriented Programming

Object Oriented Programming Object Oriented Programming 1. Graphical User Interfaces OOP10 - M. Joldoş - T.U. Cluj 1 GUI A Graphical User Interface (GUI pronounced "goo-ee") presents a userfriendly mechanism for interacting with

More information

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski CS 190 - Java Introduction to Java Andy Mroczkowski uamroczk@cs.drexel.edu Department of Computer Science Drexel University March 10, 2008 / Lecture 8 Outline Course Status Course Information & Schedule

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

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

Chapter 17 Creating User Interfaces

Chapter 17 Creating User Interfaces Chapter 17 Creating User Interfaces 1 Motivations A graphical user interface (GUI) makes a system user-friendly and easy to use. Creating a GUI requires creativity and knowledge of how GUI components work.

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

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

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling Frames, GUI and events Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling Introduction to Swing The Java AWT (Abstract Window Toolkit)

More information

More Swing. CS180 Recitation 12/(04,05)/08

More Swing. CS180 Recitation 12/(04,05)/08 More Swing CS180 Recitation 12/(04,05)/08 Announcements No lecture/labs next week Recitations and evening consulting hours will be held as usual. Debbie's study group on tuesday and office hours on thursday

More information

PIC 20A GUI with swing

PIC 20A GUI with swing PIC 20A GUI with swing Ernest Ryu UCLA Mathematics Last edited: November 22, 2017 Hello swing Let s create a JFrame. import javax. swing.*; public class Test { public static void main ( String [] args

More information

Contents Chapter 1 Introduction to Programming and the Java Language

Contents Chapter 1 Introduction to Programming and the Java Language Chapter 1 Introduction to Programming and the Java Language 1.1 Basic Computer Concepts 5 1.1.1 Hardware 5 1.1.2 Operating Systems 8 1.1.3 Application Software 9 1.1.4 Computer Networks and the Internet

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

Chapter 14. More Swing

Chapter 14. More Swing Chapter 14 More Swing Menus Making GUIs Pretty (and More Functional) Box Containers and Box Layout Managers More on Events and Listeners Another Look at the Swing Class Hierarchy Chapter 14 Java: an Introduction

More information

Is image everything?

Is image everything? Is image everything? Review Computer Graphics technology enables GUIs and computer gaming. GUI's are a fundamental enabling computer technology. Without a GUI there would not be any, or much less: Computer

More information

GUI in Java TalentHome Solutions

GUI in Java TalentHome Solutions GUI in Java TalentHome Solutions AWT Stands for Abstract Window Toolkit API to develop GUI in java Has some predefined components Platform Dependent Heavy weight To use AWT, import java.awt.* Calculator

More information

navlakhi.com / navlakhi.education / navlakhi.mobi / navlakhi.org 1

navlakhi.com / navlakhi.education / navlakhi.mobi / navlakhi.org 1 Example 1 public class ex1 extends JApplet public void init() Container c=getcontentpane(); c.setlayout(new GridLayout(5,2)); JButton b1=new JButton("Add"); JButton b2=new JButton("Search"); JLabel l1=new

More information

Basics of programming 3. Java GUI and SWING

Basics of programming 3. Java GUI and SWING Basics of programming 3 Java GUI and SWING Complex widgets Basics of programming 3 BME IIT, Goldschmidt Balázs 2 Complex widgets JList elements can be selected from a list JComboBox drop down list with

More information

JLayeredPane. Depth Constants in JLayeredPane

JLayeredPane. Depth Constants in JLayeredPane JLayeredPane Continuing on Swing Components A layered pane is a Swing container that provides a third dimension for positioning components depth or Z order. The class for the layered pane is JLayeredPane.

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

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani Module 5 The Applet Class, Swings OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani The layout manager helps lay out the components held by this container. When you set a layout to null, you tell the

More information

Summary Chapter 25 GUI Components: Part 2

Summary Chapter 25 GUI Components: Part 2 1040 Chapter 25 GUI Components: Part 2 ponent on the line. TheJTextField is added to the content pane with a call to our utility method addcomponent (declared at lines 79 83). MethodaddComponent takes

More information

Building Graphical User Interfaces. Overview

Building Graphical User Interfaces. Overview Building Graphical User Interfaces 4.1 Overview Constructing GUIs Interface components GUI layout Event handling 2 1 GUI Principles Components: GUI building blocks. Buttons, menus, sliders, etc. Layout:

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

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau List of Slides 1 Title 2 Chapter 13: Graphical user interfaces 3 Chapter aims 4 Section 2: Example:Hello world with a GUI 5 Aim 6 Hello world with a GUI 7 Hello world with a GUI 8 Package: java.awt and

More information

EVENTS, EVENT SOURCES AND LISTENERS

EVENTS, EVENT SOURCES AND LISTENERS Java Programming EVENT HANDLING Arash Habibi Lashkari Ph.D. Candidate of UTM University Kuala Lumpur, Malaysia All Rights Reserved 2010, www.ahlashkari.com EVENTS, EVENT SOURCES AND LISTENERS Important

More information

Learn Java Programming, Dr.Hashamdar. Getting Started with GUI Programming

Learn Java Programming, Dr.Hashamdar. Getting Started with GUI Programming Learn Java Programming, Dr.Hashamdar Getting Started with GUI Programming 1 Creating GUI Objects // Create a button with text OK JButton jbtok = new JButton("OK"); // Create a label with text "Enter your

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

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

Chapter 13 Lab Advanced GUI Applications

Chapter 13 Lab Advanced GUI Applications Gaddis_516907_Java 4/10/07 2:10 PM Page 113 Chapter 13 Lab Advanced GUI Applications Objectives Be able to add a menu to the menu bar Be able to use nested menus Be able to add scroll bars, giving the

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) Layout Managment 1 Hello World Often have a static method: createandshowgui() Invoked by main calling invokelater private static void createandshowgui() { } JFrame frame

More information

What Is an Event? Some event handler. ActionEvent. actionperformed(actionevent e) { }

What Is an Event? Some event handler. ActionEvent. actionperformed(actionevent e) { } CBOP3203 What Is an Event? Events Objects that describe what happened Event Sources The generator of an event Event Handlers A method that receives an event object, deciphers it, and processes the user

More information