1005ICT Object Oriented Programming Lecture Notes

Size: px
Start display at page:

Download "1005ICT Object Oriented Programming Lecture Notes"

Transcription

1 1005ICT Object Oriented Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 2,

2 20 GUI Components and Events This section develops a program with a graphical user interface, built from Swing components The problem Our client wants the Human Resource Management (HRM) system we built to retain its existing functionality, but with a Graphical user interface (GUI). They do want one extra feature. They would like to be able to view the current staff roster within the interface. 1005ICT Object Oriented Programming

3 20.2 Design For this program, there are two aspects to the design: the layout of the the GUI; and the class design GUI design We should plan the components, and how they will function. This requires both a diagram and explanatory notes. 1005ICT Object Oriented Programming

4 This is a mock up of the desired interface, a window featuring labels, a text field, a scrollable text area, and buttons. 8 X 1 New name: 2 4 Roster: Campbell Rick Aspley 3 Hire 1 Hank Zappa 2 Lady Dada Fire Retire 1005ICT Object Oriented Programming

5 Component descriptions and behaviours: 1. Label New name: indicates the purpose of the text field. 2. Text field where the name of a new employee may be entered. Should be able to hire on pressing the return/enter key. 3. Button Hire hires the new employee whose name in the text area. 4. Label Roster: indicates the purpose of the text area. 5. Text area where staff roster is displayed. It should be scrollable to accommodate a long list. 6. Button Fire fires the newest employee. 7. Button Retire retires the oldest employee. 8. Lastly, closing the frame, saves the roster and quits the program. 1005ICT Object Oriented Programming

6 Class designs We are not starting this program from scratch. We already have a variety of existing console implementations to choose from. We should start from the version that uses java.util.arraydeque, because that class has more flexibility and features than our own deque implementations. It will allow us access to all the employees, not just the first and last. It is good practice to try to reuse as much of the existing program as possible, and to avoid having duplication of code. That is, the console and GUI versions should share as much common code as possible. 1005ICT Object Oriented Programming

7 This is how the classes are associated in the old console version. Campbell +main(args : String[]) : void -load() : void -save() : void -interact() : void * -d Employee ArrayDeque The problem with this, as a starting point for development of the GUI version, is that the main class has two roles combined: managing the staff roster and providing the console user interface. Separating those into two separate classes will allow the reuse of the staff roster in the GUI version. 1005ICT Object Oriented Programming

8 The rearrangement of existing code into different classes is called refactoring. CampbellT -APP_NAME : String {readonly} -FILE_NAME : String {readonly} +main(args : String[]) : void -interact() : void 1 -roster Roster +save(filename : String) : void +load(filename : String) : void +hire(who : String) : Employee +fire() : Employee +retire() : Employee * -d Employee ArrayDeque 1005ICT Object Oriented Programming

9 class Employee no change. class Roster new, manages the roster. New methods for hiring and firing return the affected employee so that the client program can output information if it wants to. +save(filename : String) : void load the roster from a disk file, if it exists. +load(filename : String) : void saves the roster to the disk file. +hire(who : String) : Employee hires a new employee. Returns the new employee, or null if who is blank. +fire() : Employee returns the fired employee or null. +retire() : Employee returns the retired employee or null. 1005ICT Object Oriented Programming

10 class CampbellT modified, now only performs the I/O. -APP NAME : String {readonly} the name of the app. -FILE NAME : String {readonly} the name of the file to save the roster to. -roster : Roster manages the staff roster. +main(args : String[]) : void main method. -interact() : void accepts user commands and prints messages as actions are carried out. 1005ICT Object Oriented Programming

11 Now we can replace the console version of the main class with a GUI version. (We don t yet know the details of required new members.) CampbellGUI -APP_NAME : String {readonly} -FILE_NAME : String {readonly}... +main(args : String[]) : void roster Roster +save(filename : String) : void +load(filename : String) : void +hire(who : String) : Employee +fire() : Employee +retire() : Employee * -d Employee ArrayDeque 1005ICT Object Oriented Programming

12 20.3 New console implementation /* ** file: Roster.java ** author: Andrew Rock ** purpose: Roster for a dumb HRM system. */ import java.util.*; import java.io.*; public class Roster { // A deque contains the employees. private Deque<Employee> d = new ArrayDeque<Employee>(); 1005ICT Object Oriented Programming

13 These are changed to make them use the filename parameter. // save(filename) saves the names left for the // next session. public void save(string filename) { // load(filename) loads the names left from the // previous session. public void load(string filename) { Next the new methods for hiring, firing and retiring. 1005ICT Object Oriented Programming

14 // hire(who) hires a new employee. // Returns the new employee or null. public Employee hire(string who) { who = who.trim(); if (who.length() > 0) { Employee e = new Employee(who); d.addlast(e); return e; } else { return null; } } 1005ICT Object Oriented Programming

15 // fire() fires the newest employee. // Returns the fired employee or null. public Employee fire() { try { return d.removelast(); } catch (Exception e) { return null; } } 1005ICT Object Oriented Programming

16 // retire() retires the oldest employee. // Returns the retired employee or null. public Employee retire() { try { return d.removefirst(); } catch (Exception e) { return null; } } 1005ICT Object Oriented Programming

17 /* ** file: CampbellT.java ** author: Andrew Rock ** purpose: A dumb HRM system text version. */ import java.util.*; public class CampbellT { // app name private static final String APP_NAME = "Campbell"; // saved data file name private static final String FILE_NAME = APP_NAME + ".txt"; 1005ICT Object Oriented Programming

18 // the staff roster private static Roster roster = new Roster(); public static void main(string[] args) { roster.load(file_name); interact(); roster.save(file_name); } 1005ICT Object Oriented Programming

19 // interact() prompts for and processes user // commands. private static void interact() { Scanner sc = new Scanner(System.in); System.out.print("? "); String command = sc.next(); while (!command.equals("q")) { if (command.equals("h")) { Employee e = roster.hire(sc.nextline()); if (e!= null) { System.out.println(e.getName() + " is hired as employee number " + e.getid() + "."); } else { System.err.println( "No name to hire."); } 1005ICT Object Oriented Programming

20 } else if (command.equals("f")) { Employee f = roster.fire(); if (f!= null) { System.out.println("Employee " + f.getid() + ", " + f.getname() + ", is fired."); } else { System.err.println( "No-one to fire."); } } else if (command.equals("r")) { Employee r = roster.retire(); if (r!= null) { System.out.println("Employee " + r.getid() + ", " + r.getname() + ", has retired."); } else { 1005ICT Object Oriented Programming

21 } } System.err.println( "No-one to retire."); } } else { System.out.println("Bad command."); } System.out.print("? "); command = sc.next(); } 1005ICT Object Oriented Programming

22 20.4 GUI implementation main and frame We start by creating the main method and the code for putting up the frame. Mostly this is the same as we have done before in the 2D graphics examples. /* ** file: CampbellGUI.java ** author: Andrew Rock ** purpose: A dumb HRM system, with a GUI. */ import java.awt.*; import javax.swing.*; 1005ICT Object Oriented Programming

23 public class CampbellGUI { Same as the console version: // app name private static final String APP_NAME = "Campbell"; // saved data file name private static final String FILE_NAME = APP_NAME + ".txt"; // the staff roster private static Roster roster = new Roster(); 1005ICT Object Oriented Programming

24 The frame, and any components that we need to access from multiple methods, we make global. // the frame private static JFrame frame = new JFrame(APP_NAME); public static void main(string[] args) { roster.load(file_name); layoutcomponents(); addlisteners(); frame.setdefaultcloseoperation( JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setvisible(true); } 1005ICT Object Oriented Programming

25 In the main method, we: load the roster from disk; delegate the layout of the components, and the setting up of event handling to other methods; set the program to quit when the window is closed; set the size of the window (using pack() to set the minimum size that fits all the components); and make the frame visible. 1005ICT Object Oriented Programming

26 Components and layout In our previous graphics examples, we only had one component to put into the frame and it filled the content area of the frame. When we have multiple components in a frame, or any container, there are many ways that the components could be placed relative to each other. In GUI frameworks that do not have to be platform independent, the components can be placed manually using graphical tools. Such tools exist for Java, but to use them, you need to understand the code that they will generate. We will lay out our components with just Java code. 1005ICT Object Oriented Programming

27 A Container delegates the layout of the Components it contains to a LayoutManager. There are many different classes that implement the LayoutManager interface. Some are simple and only work for simple cases. The best one, for flexibility and total control, is GridBagLayout. The simplest one that is still quite powerful is javax.swing.boxlayout, and that is the only one we will use in these lecture notes. A BoxLayout can be used to lay out components along the x-axis. 1005ICT Object Oriented Programming

28 A BoxLayout can also be used to lay out components along the y-axis. By nesting Containers with BoxLayouts components may be laid out in all kinds of 2-dimensional arrangements. 1005ICT Object Oriented Programming

29 This shows how we can nest box layouts to make our GUI. X Campbell New name: Rick Aspley Hire Roster: 1 Hank Zappa 2 Lady Dada Fire Retire We will use JPanels as the containers that use the BoxLayouts. 1005ICT Object Oriented Programming

30 Here are the components that we need to declare globally: // input text field private static JTextField namefield = new JTextField(20); // Output text area: private static JTextArea rosterarea = new JTextArea(10, 25); // buttons: private static JButton hirebtn = new JButton("Hire"), firebtn = new JButton("Fire"), retbtn = new JButton("Retire"); 1005ICT Object Oriented Programming

31 Set up the panels and the box layouts and their orientations. // layoutcomponents() lays out the components. private static void layoutcomponents() { JPanel box0 = new JPanel(), box1 = new JPanel(), box2 = new JPanel(), box3 = new JPanel(); box0.setlayout(new BoxLayout(box0, BoxLayout.Y_AXIS)); box1.setlayout(new BoxLayout(box1, BoxLayout.X_AXIS)); box2.setlayout(new BoxLayout(box2, BoxLayout.Y_AXIS)); box3.setlayout(new BoxLayout(box3, BoxLayout.X_AXIS)); 1005ICT Object Oriented Programming

32 Add box0 to the frame s content area, and then nest the other three boxes. frame.add(box0); box0.add(box1); box0.add(box2); box0.add(box3); Center the nested boxes within box0. box1.setalignmentx( Component.CENTER_ALIGNMENT); box2.setalignmentx( Component.CENTER_ALIGNMENT); box3.setalignmentx( Component.CENTER_ALIGNMENT); 1005ICT Object Oriented Programming

33 Adding a border to each box allows a little spacing out. box1.setborder(new EmptyBorder(5, 5, 5, 5)); box2.setborder(new EmptyBorder(5, 5, 5, 5)); box3.setborder(new EmptyBorder(5, 5, 5, 5)); Need to add this to the top: import javax.swing.border.*; Add the components to the top box. box1.add(new JLabel("New name:")); box1.add(namefield); box1.add(hirebtn); 1005ICT Object Oriented Programming

34 Add and align the label in the middle box. JLabel rosterlbl = new JLabel("Roster:"); box2.add(rosterlbl); rosterlbl.setalignmentx( Component.LEFT_ALIGNMENT); The text area is for output only. rosterarea.seteditable(false); Fill it with the text to display. (A tostring() method needs to be added to class Roster.) rosterarea.settext(roster.tostring()); 1005ICT Object Oriented Programming

35 We don t add the text area directly. It does not have its own scrolling functionality. We embed it in a JScrollPane and add and align that. JScrollPane scroller = new JScrollPane(rosterArea); box2.add(scroller); scroller.setalignmentx( Component.LEFT_ALIGNMENT); Finally, add the hire and retire buttons to the bottom box. } box3.add(firebtn); box3.add(retbtn); 1005ICT Object Oriented Programming

36 Event handling Now we need to get the components to trigger the actions we want performed. This is done with event handling. We will set up event handling in this method. // addlisteners() adds event listeners to the // components and the frame. private static void addlisteners() { and we ll need to add this at the top: import java.awt.event.*; 1005ICT Object Oriented Programming

37 This is what happens when a user clicks a mouse with the pointer over a button in a Java program s window: The mouse hardware sends a message via its connection (say USB) to the PC hardware. The operating system combines the fact that the mouse was clicked with the current location of the pointer (which it manages) to form an event. The operating system determines what area of the display the location is in, and so what program needs to deal with the event. 1005ICT Object Oriented Programming

38 The event is sent to the program that needs it. It is sent as a message. That is, the operating system calls a method within the program. If the program is a Java program, then the message is sent to the JVM. The JVM determines which window the mouse was clicked in, and the event is sent as a message to that window. The message is sent down through the nested containers, until it reaches the button. So if we want the button to initiate some action, we have to provide the method that will be called and passed the event as an argument. 1005ICT Object Oriented Programming

39 In Java we can t just supply a method on its own to receive the event. All Java methods have to be defined in a class. For buttons, the class must implement the ActionListener interface. That interface defines just one method to implement. There will only be one instance of this class. These conditions are just right for using an anonymous inner class! button, text field,... «interface» ActionListener +actionperformed(e : ActionEvent) : void Component «anonymous» ActionListener 1005ICT Object Oriented Programming

40 We ll add a listener to the fire button first, as it is the simplest case. firebtn.addactionlistener( new ActionListener() { public void actionperformed( ActionEvent e) { roster.fire(); rosterarea.settext( roster.tostring()); } }); 1005ICT Object Oriented Programming

41 In one statement, we have defined a new, anonymous class that implements ActionListener; implemented its actionperformed method, in which: someone gets fired; and the roster text area gets updated; instantiated a single instance of the new class; and passed that instance as a parameter to addactionlistener to add this listener object to the fire button. So now the fire button can accept the event and trigger the actions we want. 1005ICT Object Oriented Programming

42 Similarly for the retire button: retbtn.addactionlistener( new ActionListener() { public void actionperformed( ActionEvent e) { roster.retire(); rosterarea.settext( roster.tostring()); } }); 1005ICT Object Oriented Programming

43 The hire button, and pressing enter in the input text field, both need to initiate the same action, so they can share the same listener. ActionListener hireal = new ActionListener() { public void actionperformed( ActionEvent e) { roster.hire(namefield.gettext()); namefield.settext(""); rosterarea.settext( roster.tostring()); } }; namefield.addactionlistener(hireal); hirebtn.addactionlistener(hireal); 1005ICT Object Oriented Programming

44 Our program can now hire and fire, but there is one problem remaining. The program will exit when the window is closed. We need an opportunity to save the roster before the program quits. We do this by listening for a window event. The process is similar. The interface WindowListener defines a windowclosing method that we can use to call roster.save, in our implementation. However WindowListener defines lots of other methods that we don t want to have to implement. 1005ICT Object Oriented Programming

45 For this reason, there is an abstract class WindowAdapter that implements all of those methods with dummy handlers. Extending that only requires implementing the method we want. «interface» WindowListener +windowclosing(e : WindowEvent) : void... WindowAdapter JFrame «anonymous» WindowAdapter 1005ICT Object Oriented Programming

46 This completes our program. } frame.addwindowlistener( new WindowAdapter(){ public void windowclosing( WindowEvent e) { roster.save(file_name); } }); Go play! 1005ICT Object Oriented Programming

47 20.5 Section summary This monster section covered: GUI design with a sketch and textual description; refactoring; separating the user interface from the rest, so it can be replaced; laying out components with BoxLayouts; components JPanel, Jlabel, JButton, JTextField, JTextArea, and EmptyBorder; event handling with interface ActionListener and abstract class WindowAdapter; and anonymous inner classes for event listeners. 1005ICT Object Oriented Programming

48 20.6 End of section feedback questions Send us your answers to these questions any time you like by clicking on them. What was the most useful topic in this section? What was the least useful topic in this section? What was the least clear topic in this section? What topic in this section would you like to like to know more about? Did you find an error in this section? 1005ICT Object Oriented Programming

1005ICT Object Oriented Programming Lecture Notes

1005ICT Object Oriented Programming Lecture Notes 1005ICT Object Oriented Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 2, 2015 1 16 Generics This section introduces generics, or parameterised

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

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

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

Building Graphical User Interfaces. GUI Principles

Building Graphical User Interfaces. GUI Principles Building Graphical User Interfaces 4.1 GUI Principles Components: GUI building blocks Buttons, menus, sliders, etc. Layout: arranging components to form a usable GUI Using layout managers. Events: reacting

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

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

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

Java & Graphical User Interface II. Wang Yang wyang AT njnet.edu.cn

Java & Graphical User Interface II. Wang Yang wyang AT njnet.edu.cn Java & Graphical User Interface II Wang Yang wyang AT njnet.edu.cn Outline Review of GUI (first part) What is Event Basic Elements of Event Programming Secret Weapon - Inner Class Full version of Event

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

MIT AITI Swing Event Model Lecture 17

MIT AITI Swing Event Model Lecture 17 MIT AITI 2004 Swing Event Model Lecture 17 The Java Event Model In the last lecture, we learned how to construct a GUI to present information to the user. But how do GUIs interact with users? How do applications

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

SINGLE EVENT HANDLING

SINGLE EVENT HANDLING SINGLE EVENT HANDLING Event handling is the process of responding to asynchronous events as they occur during the program run. An event is an action that occurs externally to your program and to which

More information

Overview. Building Graphical User Interfaces. GUI Principles. AWT and Swing. Constructing GUIs Interface components GUI layout Event handling

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

More information

More Swing. Chapter 14. Chapter 14 1

More Swing. Chapter 14. Chapter 14 1 More Swing Chapter 14 Chapter 14 1 Objectives learn to add menus, icons, borders, and scroll bars to GUIs learn to use the BoxLayout manager and the Box class learn about inner classes learn about the

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

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

Interfaces & Polymorphism part 2: Collections, Comparators, and More fun with Java graphics

Interfaces & Polymorphism part 2: Collections, Comparators, and More fun with Java graphics Interfaces & Polymorphism part 2: Collections, Comparators, and More fun with Java graphics 1 Collections (from the Java tutorial)* A collection (sometimes called a container) is simply an object that

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

Event Driven Programming

Event Driven Programming Event Driven Programming Part 1 Introduction Chapter 12 CS 2334 University of Oklahoma Brian F. Veale 1 Graphical User Interfaces So far, we have only dealt with console-based programs Run from the console

More information

AP CS Unit 11: Graphics and Events

AP CS Unit 11: Graphics and Events AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two

More information

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread G51PGP Programming Paradigms Lecture 008 Inner classes, anonymous classes, Swing worker thread 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals

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

Swing - JTextField. Adding a text field to the main window (with tooltips and all)

Swing - JTextField. Adding a text field to the main window (with tooltips and all) Swing - JTextField Adding a text field to the main window (with tooltips and all) Prerequisites - before this lecture You should have seen: The lecture on JFrame The lecture on JButton Including having

More information

Swing - JButton. Adding buttons to the main window

Swing - JButton. Adding buttons to the main window Swing - JButton Adding buttons to the main window An empty JFrame is not very useful // In some GUI class: window = new JFrame("Window example"); window.setsize(800,600); window.setdefaultcloseoperation(jframe.exit_on_close);

More information

GUI Applications. Let s start with a simple Swing application in Java, and then we will look at the same application in Jython. See Listing 16-1.

GUI Applications. Let s start with a simple Swing application in Java, and then we will look at the same application in Jython. See Listing 16-1. GUI Applications The C implementation of Python comes with Tkinter for writing Graphical User Interfaces (GUIs). The GUI toolkit that you get automatically with Jython is Swing, which is included with

More information

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical

More information

Swing - JLabel. Adding a text (and HTML) labels to a GUI

Swing - JLabel. Adding a text (and HTML) labels to a GUI Swing - JLabel Adding a text (and HTML) labels to a GUI Prerequisites - before this lecture You should have seen: The lecture on JFrame The lecture on JButton The lectuer on JTextField Including having

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

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

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

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

Programming Languages and Techniques (CIS120e)

Programming Languages and Techniques (CIS120e) Programming Languages and Techniques (CIS120e) Lecture 29 Nov. 19, 2010 Swing I Event- driven programming Passive: ApplicaHon waits for an event to happen in the environment When an event occurs, the applicahon

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

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

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

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

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

Jonathan Aldrich Charlie Garrod

Jonathan Aldrich Charlie Garrod Principles of Software Construction: Objects, Design, and Concurrency (Part 3: Design Case Studies) Introduction to GUIs Jonathan Aldrich Charlie Garrod School of Computer Science 1 Administrivia Homework

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

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

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

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

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

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms. Java GUI Windows Events Drawing 1 Java GUI Toolkits Toolkit AWT Description Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

More information

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline Sequential vs. Event-driven Programming Reacting to the user GUI Program Organization Let s digress briefly to examine the organization of our GUI programs We ll do this in stages, by examining three example

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

First Name: AITI 2004: Exam 2 July 19, 2004

First Name: AITI 2004: Exam 2 July 19, 2004 First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: Standard Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand

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

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal Objectives: To gain experience with the programming of: 1. Graphical user interfaces (GUIs), 2. GUI components, and 3. Event handling (required

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

CS Exam 1 Review Suggestions

CS Exam 1 Review Suggestions CS 235 - Fall 2015 - Exam 1 Review Suggestions p. 1 last modified: 2015-09-30 CS 235 - Exam 1 Review Suggestions You are responsible for material covered in class sessions, lab exercises, and homeworks;

More information

Programming Language Concepts: Lecture 8

Programming Language Concepts: Lecture 8 Programming Language Concepts: Lecture 8 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 8, 11 February 2009 GUIs and event

More information

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4. 1 - What if the main method is declared as private? 1. The program does not compile 2. The program compiles but does not run 3. The program compiles and runs properly ( From Lectuer # 2) 4. The program

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

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing. COSC User Interfaces Module 3 Sequential vs. Event-driven Programming Example Programs DemoLargestConsole.java DemoLargestGUI.java Demo programs will be available on the course web page. GUI Program Organization

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

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

GUI Forms and Events, Part II

GUI Forms and Events, Part II GUI Forms and Events, Part II Quick Start Compile step once always mkdir labs javac PropertyTax6.java cd labs Execute step mkdir 6 java PropertyTax6 cd 6 cp../5/propertytax5.java PropertyTax6.java Submit

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

Homework 6 part 2: Turtle Etch-A-Sketch (40pts)

Homework 6 part 2: Turtle Etch-A-Sketch (40pts) Homework 6 part 2: Turtle Etch-A-Sketch (40pts) DUE DATE: Friday March 28, 7pm with 5 hour grace period Now that you have done part 1 of Homework 6, Train Your Turtle to Draw on Command, you are ready

More information

Introduction This assignment will ask that you write a simple graphical user interface (GUI).

Introduction This assignment will ask that you write a simple graphical user interface (GUI). Computing and Information Systems/Creative Computing University of London International Programmes 2910220: Graphical Object-Oriented and Internet programming in Java Coursework one 2011-12 Introduction

More information

COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) )

COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) ) COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) ) Course Evaluations Please do these. -Fast to do -Used to

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

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Glossary of Terms 2-4 Step by Step Instructions 4-7 HWApp 8 HWFrame 9 Never trust a computer

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

State Application Using MVC

State Application Using MVC State Application Using MVC 1. Getting ed: Stories and GUI Sketch This example illustrates how applications can be thought of as passing through different states. The code given shows a very useful way

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

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13 CONTENTS Chapter 1 Getting Started with Java SE 6 1 Introduction of Java SE 6... 3 Desktop Improvements... 3 Core Improvements... 4 Getting and Installing Java... 5 A Simple Java Program... 10 Compiling

More information

CS 251 Intermediate Programming GUIs: Event Listeners

CS 251 Intermediate Programming GUIs: Event Listeners CS 251 Intermediate Programming GUIs: Event Listeners Brooke Chenoweth University of New Mexico Fall 2017 What is an Event Listener? A small class that implements a particular listener interface. Listener

More information

Introduction to GUIs. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2014

Introduction to GUIs. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2014 Introduction to GUIs Principles of Software Construction: Objects, Design, and Concurrency Jonathan Aldrich and Charlie Garrod Fall 2014 Slides copyright 2014 by Jonathan Aldrich, Charlie Garrod, Christian

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

ITEC 120 4/14/11. Review. Need. Objectives. GUI basics JFrame JPanel JLabel, JButton, JTextField Layout managers. Lecture 38 GUI Interactivity

ITEC 120 4/14/11. Review. Need. Objectives. GUI basics JFrame JPanel JLabel, JButton, JTextField Layout managers. Lecture 38 GUI Interactivity Review ITEC 120 Lecture 38 GUI GUI basics JFrame JPanel JLabel, JButton, JTextField Layout managers Flow / Box Border / Grid Objectives Need Add interactivity When you click on a button How does your code

More information

CS415 Human Computer Interaction

CS415 Human Computer Interaction CS415 Human Computer Interaction Lecture 5 HCI Design Methods (GUI Builders) September 18, 2015 Sam Siewert A Little Humor on HCI Sam Siewert 2 WIMP GUI Builders The 2D GUI is the Killer App for WIMP Floating

More information

We are on the GUI fast track path

We are on the GUI fast track path We are on the GUI fast track path Chapter 13: Exception Handling Skip for now Chapter 14: Abstract Classes and Interfaces Sections 1 9: ActionListener interface Chapter 15: Graphics Skip for now Chapter

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

Class 16: The Swing Event Model

Class 16: The Swing Event Model Introduction to Computation and Problem Solving Class 16: The Swing Event Model Prof. Steven R. Lerman and Dr. V. Judson Harward 1 The Java Event Model Up until now, we have focused on GUI's to present

More information

Client-side GUI. A simple Swing-gui for searching for proudcts

Client-side GUI. A simple Swing-gui for searching for proudcts Client-side GUI A simple Swing-gui for searching for proudcts Working from a sketch to a rough GUI We make a list of the features / requirements We ll then start with a sketch of how a GUI for searching

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

COMPSCI 230. Software Design and Construction. Swing

COMPSCI 230. Software Design and Construction. Swing COMPSCI 230 Software Design and Construction Swing 1 2013-04-17 Recap: SWING DESIGN PRINCIPLES 1. GUI is built as containment hierarchy of widgets (i.e. the parent-child nesting relation between them)

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

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

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

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

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

Chapter 1 GUI Applications

Chapter 1 GUI Applications Chapter 1 GUI Applications 1. GUI Applications So far we've seen GUI programs only in the context of Applets. But we can have GUI applications too. A GUI application will not have any of the security limitations

More information

H212 Introduction to Software Systems Honors

H212 Introduction to Software Systems Honors Introduction to Software Systems Honors Lecture #19: November 4, 2015 1/14 Third Exam The third, Checkpoint Exam, will be on: Wednesday, November 11, 2:30 to 3:45 pm You will have 3 questions, out of 9,

More information

G51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions

G51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions G51PGP Programming Paradigms Lecture 009 Concurrency, exceptions 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals = new Animal[6]; animals[0]

More information

Final Exam CS 251, Intermediate Programming December 13, 2017

Final Exam CS 251, Intermediate Programming December 13, 2017 Final Exam CS 251, Intermediate Programming December 13, 2017 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible

More information

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7...

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7... Table of Contents Chapter 1 Getting Started with Java SE 7 1 Introduction of Java SE 7... 2 Exploring the Features of Java... 3 Exploring Features of Java SE 7... 4 Introducing Java Environment... 5 Explaining

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

Come & Join Us at VUSTUDENTS.net

Come & Join Us at VUSTUDENTS.net Come & Join Us at VUSTUDENTS.net For Assignment Solution, GDB, Online Quizzes, Helping Study material, Past Solved Papers, Solved MCQs, Current Papers, E-Books & more. Go to http://www.vustudents.net and

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

Adding Buttons to StyleOptions.java

Adding Buttons to StyleOptions.java Adding Buttons to StyleOptions.java The files StyleOptions.java and StyleOptionsPanel.java are from Listings 5.14 and 5.15 of the text (with a couple of slight changes an instance variable fontsize is

More information

Using Several Components

Using Several Components Ch. 16 pt 2 GUIs Using Several Components How do we arrange the GUI components? Using layout managers. How do we respond to event from several sources? Create separate listeners, or determine the source

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Overview

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