3 Combining Widgets to create Graphical User Interfaces
|
|
- Maria Henry
- 6 years ago
- Views:
Transcription
1 (Graphical User Interfaces - 41) 3 Combining Widgets to create Graphical User Interfaces 3.1 The Ressource Concept Goal: How to compose widgets to create complete user interfaces Problem: Composition has significant graphical, visual, usage aspects Programmers typically do not have the qualification Ideal Solution: Tools for user interface specialists, non-programmers, to compose GUIs from widgets: Interface Builder Selection and layout of widgets, definition of parameter values Technical Basis: Separation of widgets from the program code ressource concept Vorlesung Basic Idea: Many properties of widgets can be seen as data: Text Font Colour Border Thickness Border Style (simple line, double line) Enable/disable status Position (x-y-coordinates) Modification of these parameters in a tool without modifying the widget source code (ressource editors, interface builder) Visually/graphically working tool (instead of coding program parts) Mechanisms for reading parameter values from files (ressources, properties) Textual representation of the widgets within the ressources (Graphical User Interfaces - 42) Vorlesung
2 (Graphical User Interfaces - 43) Widgets are combined to complete dialogues: Example: Menus Menu Header Label Menu Header Font Menu Item Font List Of Menu Item Label Menu Item Checked Menu Item Id Definition of "container -widgets widgets containing other widgets Menu Header Label = "Datei" Menu Header Font = "Arial" Menu Item Font = "Arial" Menu Item Label = "Neu" Menu Item Checked = false Menu Item Id = 1 Menu Item Label = "Öffnen" Menu Item Checked = false Menu Item Id = 1 Example: dialogue boxes Information about contained widgets and their relative positions within the dialogue box E.g.: Group Boxes (Border, Border Text, contained widgets) Vorlesung Practical Example from a Delphi-4 implementation (Object Pascal): object EigenschaftenForm: TEigenschaftenForm Left = 256 Top = 79 Width = 453 Height = 415 Caption = 'Eigenschaften' Color = clbtnface Font.Charset = DEFAULT_CHARSET Font.Color = clwindowtext Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False OnActivate = FormActivate PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel Left = 24 Top = 8 Width = 108 Height = 13 Caption = 'Strichstärke (Pixel)' (Graphical User Interfaces - 44) Vorlesung
3 (Graphical User Interfaces - 45) Font.Charset = DEFAULT_CHARSET Font.Color = clwindowtext Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [fsbold] ParentFont = False end object SpinEdit1: TSpinEdit Left = 24 Top = 56 Width = 49 Height = 22 Font.Charset = DEFAULT_CHARSET Font.Color = clwindowtext Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] MaxValue = 100 MinValue = 1 ParentFont = False TabOrder = 0 Value = 1 OnExit = SpinEdit1Change end object SchriftResetButton: TButton Left = 256 Top = 120 Width = 137 Height = 17 Caption = 'Standard wiederherstellen' TabOrder = 5 OnClick = SchriftResetButtonClick end object PfeilGefuelltCB: TCheckBox Left = 176 Top = 296 Width = 65 Height = 25 Caption = 'Gefüllt' TabOrder = 12 OnExit = PfeilGefuelltCBExit end end Vorlesung 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-46) How are ressources organized at best? Binaries? Too hardware dependent! Text files! Explicit notation of widget properties, assignment with text handling functions drawprog.fontsheet.style.backgroundcolor: red drawprog*backgroundcolor: blue Interactive specification: ressource editors How are ressources linked to executable programs? Macintosh: Combination of ressources and binaries in one single file X-UNIX: Paths: Specification of two files for code and ressources (flexible, error prone) MS Windows: Ressource- Compiler translates ressources into data segments, added to binaries (exe files) (Icon assignment from.exe files)
4 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-47) 3.2 Interface Builders Creation of "ressources" with appropriate interface builder tools 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-48) Development of dialogue boxes by combining predefined widgets:
5 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-49) Linking event handlers: procedure TEigenschaftenForm.OKButtonClick (Sender: TObject); begin Hide; end; 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-50) Large parts of the code are generated (example Object Pascal): unit Eigenschaften; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Spin; type TEigenschaftenForm = class(tform) Label1: TLabel; SpinEdit1: TSpinEdit; Label2: TLabel; SpinEdit3: TSpinEdit; Label8: TLabel; SpinEdit6: TSpinEdit; Label9: TLabel; Label10: TLabel; SpinEdit7: TSpinEdit; PfeilGefuelltCB: TCheckBox; PfeilResetButton: TButton;
6 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-51) procedure SpinEdit1Change(Sender: TObject); procedure SpinEdit2Change(Sender: TObject); procedure FormActivate(Sender: TObject); procedure SpinEdit3Change(Sender: TObject); procedure SchriftResetButtonClick(Sender: TObject); procedure StrichResetButtonClick(Sender: TObject); procedure OKButtonClick(Sender: TObject); procedure CancelButtonClick(Sender: TObject); procedure SpinEdit4Exit(Sender: TObject); procedure SpinEdit5Exit(Sender: TObject); procedure AbstandResetButtonClick(Sender: TObject); procedure PfeilResetButtonClick(Sender: TObject); procedure SpinEdit6Exit(Sender: TObject); procedure SpinEdit7Exit(Sender: TObject); procedure PfeilGefuelltCBExit(Sender: TObject); end; var EigenschaftenForm: TEigenschaftenForm; AlteNormaleStrichstaerke: integer; AlteDefinierendeStrichstaerke: integer; , Prof. Dr. Gerd Szwillus (Graphical User Interfaces-52) Parts of the code are then provided by hand implementation $R *.DFM. procedure TEigenschaftenForm.SpinEdit2Change(Sender: TObject); begin DefinierendeStrichstaerke := SpinEdit2.Value; end;. procedure TEigenschaftenForm.OKButtonClick(Sender: TObject); begin Hide; end;. end.
7 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-53) Visual Must (in Java for Java) Interface Builder for Java programs written complete in Java , Prof. Dr. Gerd Szwillus (Graphical User Interfaces-54) 4 Programming Graphical User Interfaces in Java Program structure ( Event-Based-Programming, 30) For every single window (dialogue box, alert window, input form, ) to be displayed Create the window itself as Java object of an appropriate class Set initial properties of the window Create the elements contained in the window as Java object of an appropriate class Set initial properties of the elements Define layout details Place elements graphically "into" the window Display / Hide the window relative to program logic For every element with customized user interaction Provide code for capturing user interaction (including its parameters) Define what happens as a reaction to this user interaction
8 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-55) 4.1 Display Part Creating a window Select the type of window (JFrame, JDialog, ) from an appropriate widget library (e.g. javax.swing) Check the Java documentation about this type of object ( Include a new-statement in your program to create such an object with the appropriate constructor (rare) or Define a subclass of the window type class to be able to overwrite methods of the class and to add individual data a structures and methods of your application (typical) Example: class Durchschnitt extends JFrame Set initial properties of the window 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-56) Add method calls (typical: within the constructor) setting window parameters setsize, setlocation, settitle, setresizable, setdefaultcloseoperation, setcursor, setbackground, Example: Durchschnitt() extends JFrame Durchschnitt() setsize(250, 200); setlocation(300, 300); settitle("calculate Degree Average"); setvisible(true); setdefaultcloseoperation(exit_on_close);
9 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-57) Define layout details Select one of the available layout handler options BorderLayout, BoxLayout, CardLayout, FlowLayout, GridBagLayout, GridLayout, Assignment of a layout manager to a window by "setting" it for the window's content pane, optionally with additional parameters (i.e. creating a layout manager object with appropriate parameters and passing it on to the set method): setlayout(new GridLayout(3, 2)); setlayout(new FlowLayout(FlowLayout.LEFT)); // 3 rows, 2 columns // alignment along the left border Once the layout is defined, all elements placed "onto" the window are layed out according to these rules FlowLayout(FlowLayout.CENTER) is the default layout Example: Durchschnitt() extends JFrame Durchschnitt() getcontentpane().setlayout(new FlowLayout()); 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-58) Place elements graphically on the window Adding Java objects representing widgets to the window's contentpane, with its add()-method element = new JButton("OK"); // element is a Swing object of the UI (e.g. a button) getcontentpane().add(element); The order is relevant (first, second, third, ) as objects are layed out in that order The place of creation is irrelevant Possible: class X JLabel jl = new JLabel(""); class Y JFrame f = new JFrame("My Window"); X x = new X(); Y() f.getcontentpane().add(x.jl); Typical: class Z extends JFrame Z() getcontentpane().add(new JLabel(""));
10 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-59) Example: class Durchschnitt extends JFrame JLabel prompt = new JLabel("Enter the first degree"); JTextField numberinput = new JTextField("(integer number)", 20); JButton calculate = new JButton("Calculate"); JLabel result = new JLabel("***"); Durchschnitt() getcontentpane().add(prompt); getcontentpane().add(numberinput); getcontentpane().add(calculate); getcontentpane().add(result); Display / Hide the window relative to program logic setvisible(true) resp. setvisible(false); Avoid screen flashing by modifying invisible widgets only, i.e. prepare widgets for showing in the invisible state Default: objects are visible with their parent objects; frames/dialogues are initially invisible. 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-60) Example summarized (display part only): class Durchschnitt extends JFrame JLabel prompt = new JLabel("Enter the first degree"); JTextField numberinput = new JTextField("(integer number)", 20); JButton calculate = new JButton("Calculate"); JLabel result = new JLabel("***"); Durchschnitt() getcontentpane().setlayout(new FlowLayout()); getcontentpane().add(prompt); getcontentpane().add(numberinput); getcontentpane().add(calculate); getcontentpane().add(result); setsize(250, 200); setlocation(300, 300); settitle("calculate Degree Average"); setvisible(true); setdefaultcloseoperation(exit_on_close);
11 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-61) 4.2 Interaction Part 4.2.1Widget Interaction Provide code for capturing user interaction Input operation are "observed" by ActionListener objects An ActionListener object owns a void actionperformed(actionevent e) method ActionListener is a Java interface requesting only the actionperformed()-method X is an action listener class X implements ActionListener public void actionperformed(actionevent e) When the user performs an action on the UI element, the actionperformed-method is called with the executed action passed as ActionEvent parameter object for evaluation 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-62) To capture the user interactions of a UI element b (e.g. JButton b) with action listener x (e.g. X x), x is added to b as action listener with the addactionlistener method x is an action listener for b (rare) JButton b = new JButton(); X x = new X(); b.addactionlistener(x); F is action listener for the button b it contains (typical) class F extends JFrame implements ActionListener JButton b = new JButton(); public void actionperformed(actionevent e) F() b.addactionlistener(this);
12 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-63) Define what happens as a reaction to this user interaction ActionEvent objects provide information about what has happened getsource() from which object does the action event result (e.g. JButton b) getid() what is the type of action event getcommandstring() which command string is associated with the event getmodifiers() which additional keys were pressed (Ctrl, Shift, Alt, ) Typical structure of actionperformed-methods public void actionperformed(actionevent e) if (e.getsource()==bok) // action for JButton bok press if (e.getsource()==bcancel) // action for JButton bcancel press else 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-64) UI Elements can be assigned individual "action" strings JButton bok = new JButton ("OK"); bok.setactioncommand("in Ordnung"); "Action command" strings can be read from the ActionEvent steming from the button public void actionperformed(actionevent e) if (e.getactioncommand().equals("in Ordnung")) // action for JButton bok press if (e.getactioncommand().equals) // action for other Button
13 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-65) Example summarized (interaction part only): class Durchschnitt extends JFrame implements ActionListener public void actionperformed(actionevent e) if (e.getsource()==numberinput) int n = Integer.parseInt(numberInput.getText()); d.addnumber(n); calculate.setenabled(true); prompt.settext(""+d.getnumber()+" degrees entered. Enter next"); numberinput.settext(""); else if (e.getsource()==calculate) result.settext("average is "+d.getaverage()); calculate.setenabled(false); 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-66) 4.2.2Mouse Interaction Provide code for capturing user interaction Mouse operations are observed by MouseListener and MouseMotionListener objects o A MouseListener object owns mouseclicked, mouseentered, mouseexited, mousepressed,andmousereleased methods. o A MouseMotionListener object owns mousemoved and mousedragged methods Use MouseMotionListener only, if interested in explicit programmed action for every mouse movement (efficiency!) Define what happens as a reaction to mouse events User performs mouse actions appropriate event handler is called MouseEvent parameter object for evaluation, gives additional information such as getx(), gety(), getpoint() at which position has the mouse event happened getclickcount() number of mouse clicks (2 = double click)
14 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-67) Example for a mouse listener/mouse motion listener program: Permanently display the mouse coordinates and the mouse key status in the title bar of the window Push places a red circle on the canvas Release places a blue circle and a green line from the push position to the release position on the canvas 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-68) Program Concept class MyFrame extends MyFrame is doing "everything" MyFrame has two Point type attributes a and b, which store the last two push-release positions Whenever the frame is repainted, the necessary (one or two) circles and line are drawn onto the canvas class MyFrame extends JFrame Point a = null; Point b = null; MyFrame() public void paint() // dependent on Points a and b
15 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-69) The constructor of MyFrame: MyFrame() addmouselistener(..); addmousemotionlistener(..); setlocation(100, 100); setsize(400, 400); setdefaultcloseoperation(exit_on_close); setvisible(true); A MouseMotionListener is added to MyFrame, constantly re-writing the window title (Java construct: object instance of an anonymous class, MouseMotionAdapter implements all MouseMotionListener methods "doing nothing") addmousemotionlistener( new MouseMotionAdapter() public void mousemoved(mouseevent m) settitle("up "+m.getx()+" "+m.gety()); ); public void mousedragged(mouseevent m) settitle("down "+m.getx()+" "+m.gety()); 2002, Prof. Dr. Gerd Szwillus (Graphical User Interfaces-70) A MouseListener is added to MyFrame, reacting on "press" and "release" addmouselistener( new MouseAdapter() public void mousepressed(mouseevent m) a = m.getpoint(); // store "first" point b = null; // "second" point unknown repaint(); ); public void mousereleased(mouseevent m) b = m.getpoint(); // store "second" point repaint();
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 informationUnit 7: Event driven programming
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 7: Event driven programming 1 1. Introduction 2.
More informationTopic 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 informationTopic 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 informationGraphical 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(listener)... MouseListener, ActionLister. (adapter)... MouseAdapter, ActionAdapter. java.awt AWT Abstract Window Toolkit GUI
51 6!! GUI(Graphical User Interface) java.awt javax.swing (component) GUI... (container) (listener)... MouseListener, ActionLister (adapter)... MouseAdapter, ActionAdapter 6.1 GUI(Graphics User Interface
More informationCSEN401 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 informationAP 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 informationGUI DYNAMICS Lecture July 26 CS2110 Summer 2011
GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI Statics and GUI Dynamics 2 Statics: what s drawn on the screen Components buttons, labels, lists, sliders, menus,... Containers: components that contain
More informationMarcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science
Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science mluckner@mini.pw.edu.pl http://www.mini.pw.edu.pl/~lucknerm } Abstract Window Toolkit Delegates creation and
More informationMethod Of Key Event Key Listener must implement three methods, keypressed(), keyreleased() & keytyped(). 1) keypressed() : will run whenever a key is
INDEX Event Handling. Key Event. Methods Of Key Event. Example Of Key Event. Mouse Event. Method Of Mouse Event. Mouse Motion Listener. Example of Mouse Event. Event Handling One of the key concept in
More informationGUI 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 informationIntroduction 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 informationLecture 5: Java Graphics
Lecture 5: Java Graphics CS 62 Spring 2019 William Devanny & Alexandra Papoutsaki 1 New Unit Overview Graphical User Interfaces (GUI) Components, e.g., JButton, JTextField, JSlider, JChooser, Containers,
More informationPROGRAMMING 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 informationJava GUI Design: the Basics
Java GUI Design: the Basics Daniel Brady July 25, 2014 What is a GUI? A GUI is a graphical user interface, of course. What is a graphical user interface? A graphical user interface is simply a visual way
More informationCS 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 informationJava: Graphical User Interfaces (GUI)
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, and Bertrand Meyer Java: Graphical User Interfaces (GUI) With material from Christoph Angerer The essence of the Java Graphics API Application
More informationGraphical User Interfaces 2
Graphical User Interfaces 2 CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2014 2011 Extending JFrame Dialog boxes Overview Ge
More informationCS 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 informationPIC 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 informationGUI 4.1 GUI GUI MouseTest.java import javax.swing.*; import java.awt.*; import java.awt.event.*; /* 1 */
25 4 GUI GUI GUI 4.1 4.1.1 MouseTest.java /* 1 */ public class MouseTest extends JApplet implements MouseListener /* 2 */ { int x=50, y=20; addmouselistener(this); /* 3 */ super.paint(g); /* 4 */ g.drawstring("hello
More informationControl 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 informationGraphical User Interfaces 2
Graphical User Interfaces 2 CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Ge?ng user input Overview Displaying message or error Listening for
More informationFrames, 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 informationClass 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 informationGraphical 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 informationJava 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 informationAll 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 informationGraphical 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 informationAdvanced Java Unit 6: Review of Graphics and Events
Advanced Java Unit 6: Review of Graphics and Events This is a review of the basics of writing a java program that has a graphical interface. To keep things simple, all of the graphics programs will follow
More informationLecture 3: Java Graphics & Events
Lecture 3: Java Graphics & Events CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki Text Input Scanner class Constructor: myscanner = new Scanner(System.in); can use file instead of System.in new Scanner(new
More informationPackages: 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 informationTo gain experience using GUI components and listeners.
Lab 5 Handout 7 CSCI 134: Fall, 2017 TextPlay Objective To gain experience using GUI components and listeners. Note 1: You may work with a partner on this lab. If you do, turn in only one lab with both
More informationG51PGP 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 informationJFrame In Swing, a JFrame is similar to a window in your operating system
JFrame In Swing, a JFrame is similar to a window in your operating system All components will appear inside the JFrame window Buttons, text labels, text fields, etc. 5 JFrame Your GUI program must inherit
More informationKF5008 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 informationEvent Driven Programming
Event Driven Programming 1. Objectives... 2 2. Definitions... 2 3. Event-Driven Style of Programming... 2 4. Event Polling Model... 3 5. Java's Event Delegation Model... 5 6. How to Implement an Event
More information2IS45 Programming
Course Website Assignment Goals 2IS45 Programming http://www.win.tue.nl/~wsinswan/programmeren_2is45/ Rectangles Learn to use existing Abstract Data Types based on their contract (class Rectangle in Rectangle.
More informationUser 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 informationStarting 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 informationCourse 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 informationAP CS Unit 12: Drawing and Mouse Events
AP CS Unit 12: Drawing and Mouse Events A JPanel object can be used as a container for other objects. It can also be used as an object that we can draw on. The first example demonstrates how to do that.
More informationComputer Science 210: Data Structures. Intro to Java Graphics
Computer Science 210: Data Structures Intro to Java Graphics Summary Today GUIs in Java using Swing in-class: a Scribbler program READING: browse Java online Docs, Swing tutorials GUIs in Java Java comes
More informationCPS122 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 informationIntroduction 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 informationWindow 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 informationBuilding 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 informationJava 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 informationJava 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 informationAP Computer Science Unit 13. Still More Graphics and Animation.
AP Computer Science Unit 13. Still More Graphics and Animation. In this unit you ll learn about the following: Mouse Motion Listener Suggestions for designing better graphical programs Simple game with
More informationGraphics. Lecture 18 COP 3252 Summer June 6, 2017
Graphics Lecture 18 COP 3252 Summer 2017 June 6, 2017 Graphics classes In the original version of Java, graphics components were in the AWT library (Abstract Windows Toolkit) Was okay for developing simple
More informationGraphical User Interface Programming
Graphical User Interface Programming Michael Brockway January 14, 2015 Graphical User Interfaces Users interact with modern application programs using graphical components such as windows, buttons (plain,
More informationCS 170 Java Programming 1. Week 9: Learning about Loops
CS 170 Java Programming 1 Week 9: Learning about Loops What s the Plan? Topic 1: A Little Review ACM GUI Apps, Buttons, Text and Events Topic 2: Learning about Loops Different kinds of loops Using loops
More informationPart 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 informationH212 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 informationProgramming 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 informationGraphical 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 informationJava Mouse Actions. C&G criteria: 5.2.1, 5.4.1, 5.4.2,
Java Mouse Actions C&G criteria: 5.2.1, 5.4.1, 5.4.2, 5.6.2. The events so far have depended on creating Objects and detecting when they receive the event. The position of the mouse on the screen can also
More information(Incomplete) History of GUIs
CMSC 433 Programming Language Technologies and Paradigms Spring 2004 Graphical User Interfaces April 20, 2004 (Incomplete) History of GUIs 1973: Xerox Alto 3-button mouse, bit-mapped display, windows 1981:
More informationGUI Software Architecture
GUI Software Architecture P2: Requirements Analysis User Analysis Task Analysis Problem Scenarios Usability Criteria Scenario Your engineers just developed a new desktop computer. They give you the following
More informationGraphical User Interface (Part-1) Supplementary Material for CPSC 233
Graphical User Interface (Part-1) Supplementary Material for CPSC 233 Introduction to Swing A GUI (graphical user interface) is a windowing system that interacts with the user The Java AWT (Abstract Window
More informationI/O Framework and Case Study. CS151 Chris Pollett Nov. 2, 2005.
I/O Framework and Case Study CS151 Chris Pollett Nov. 2, 2005. Outline Character Streams Random Access Files Design case study Planning Iterations Character Streams Java internally represents strings as
More informationFirstSwingFrame.java Page 1 of 1
FirstSwingFrame.java Page 1 of 1 2: * A first example of using Swing. A JFrame is created with 3: * a label and buttons (which don t yet respond to events). 4: * 5: * @author Andrew Vardy 6: */ 7: import
More informationOOP Assignment V. For example, the scrolling text (moving banner) problem without a thread looks like:
OOP Assignment V If we don t use multithreading, or a timer, and update the contents of the applet continuously by calling the repaint() method, the processor has to update frames at a blinding rate. Too
More informationCS 2113 Software Engineering
CS 2113 Software Engineering Java 5 - GUIs Import the code to intellij https://github.com/cs2113f18/template-j-5.git Professor Tim Wood - The George Washington University Class Hierarchies Abstract Classes
More informationCommand-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 informationPart 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 informationGraphic 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 informationExample: Building a Java GUI
Steven Zeil October 25, 2013 Contents 1 Develop the Model 2 2 Develop the layout of those elements 3 3 Add listeners to the elements 9 4 Implement custom drawing 12 1 The StringArt Program To illustrate
More informationHanley 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 informationJava & 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 informationExample: Building a Java GUI
Steven Zeil October 25, 2013 Contents 1 Develop the Model 3 2 Develop the layout of those elements 4 3 Add listeners to the elements 12 4 Implement custom drawing 15 1 The StringArt Program To illustrate
More informationCS11 Java. Fall Lecture 3
CS11 Java Fall 2014-2015 Lecture 3 Today s Topics! Class inheritance! Abstract classes! Polymorphism! Introduction to Swing API and event-handling! Nested and inner classes Class Inheritance! A third of
More informationAgenda. 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 informationMIT 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 informationGUI Programming: Swing and Event Handling
GUI Programming: Swing and Event Handling Sara Sprenkle 1 Announcements No class next Tuesday My Fourth of July present to you: No quiz! Assignment 3 due today Review Collections: List, Set, Map Inner
More information12/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 informationPreviously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components
CS112-Section2 Hakan Guldas Burcin Ozcan Meltem Kaya Muge Celiktas Notes of 6-8 May Graphics Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how
More informationDatenbank-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 informationAdvanced Java Programming
Advanced Java Programming Shmulik London Lecture #5 GUI Programming Part I AWT & Basics Advanced Java Programming / Shmulik London 2006 Interdisciplinary Center Herzeliza Israel 1 Agenda AWT & Swing AWT
More informationWindow 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 informationCPS122 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 informationCSC207H: Software Design Lecture 11
CSC207H: Software Design Lecture 11 Wael Aboelsaadat wael@cs.toronto.edu http://ccnet.utoronto.ca/20075/csc207h1y/ Office: BA 4261 Office hours: R 5-7 Acknowledgement: These slides are based on material
More informationGraphics User Defined Forms, Part I
Graphics User Defined Forms, Part I Quick Start Compile step once always mkdir labs javac PropertyTax5.java cd labs mkdir 5 Execute step cd 5 java PropertyTax5 cp /samples/csc/156/labs/5/*. cp PropertyTax1.java
More informationIntroduction. 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 informationCSIS 10A Assignment 7 SOLUTIONS
CSIS 10A Assignment 7 SOLUTIONS Read: Chapter 7 Choose and complete any 10 points from the problems below, which are all included in the download file on the website. Use BlueJ to complete the assignment,
More informationHandout 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 informationGraphical 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 informationParts 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 informationCOMPSCI 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 informationWindow 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 informationGUI Event Handlers (Part I)
GUI Event Handlers (Part I) 188230 Advanced Computer Programming Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University 1 Agenda General event
More informationTYPES OF INTERACTORS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill
TYPES OF INTERACTORS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill dewan@cs.unc.edu Code available at: https://github.com/pdewan/colabteaching PRE-REQUISITES Model-
More informationChapter 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 informationDM550 / 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 informationCSE 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 informationUnit 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 information11/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 informationCOSC 123 Computer Creativity. Graphics and Events. Dr. Ramon Lawrence University of British Columbia Okanagan
COSC 123 Computer Creativity Graphics and Events Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Key Points 1) Draw shapes, text in various fonts, and colors. 2) Build
More information