ITEC220 GUI Lecture – Part 2 References

Slides:



Advertisements
Similar presentations
ITEC220 GUI Lecture – Part 2 References  Java Software Solutions,” by Lewis & Loftus  Chapter 7  Chapter 8  Chapter 9  Java Foundations-Introduction.
Advertisements

Chapter 9 Polymorphism. © 2004 Pearson Addison-Wesley. All rights reserved9-2 Polymorphism Polymorphism (having many forms) is an object- oriented concept.
Chapter Day 23. © 2007 Pearson Addison-Wesley. All rights reserved Agenda Day 23 Problem set 4 Due Problem set 5 Posted (Last one)  Due Dec 8 Capstones.
Chapter Day 10. © 2007 Pearson Addison-Wesley. All rights reserved4-2 Agenda Day 10 Questions from last Class?? Problem set 2 posted  10 programs from.
Chapter 8: Animation Copyright 2002, Matthew Evett. These slides are based on slides copyrighted by John Lewis and William Loftus, 2002, and used with.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Chapter 9 Polymorphism 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter Day 9. © 2007 Pearson Addison-Wesley. All rights reserved4-2 Agenda Day 8 Questions from last Class?? Problem set 2 posted  10 programs from.
Chapter Day 19. © 2007 Pearson Addison-Wesley. All rights reserved7-2 Agenda Day 19 Problem set 3 Corrected  1 A, 2 B’s and 1 D Problem set 4 Posted.
ELC 312 Day 16. © 2004 Pearson Addison-Wesley. All rights reserved Agenda Questions? Capstone Proposals Due Problem set 3 Corrected  Poor performance.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
10-1 Exceptions An exception is an object that describes an unusual or erroneous situation Exceptions are thrown by a program, and may be caught and handled.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Lesson 1 Introduction.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Graphical User Interfaces Revisited Material from Chapters
Chapter 5: Enhancing Classes Presentation slides for Java Software Solutions Foundations of Program Design Second Edition by John Lewis and William Loftus.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Event Driven Programming, The.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 21.1 Test-Driving the Painter Application.
IM103 week 11 Part 2 P532 Case Study part 2: the Airport GUI Learning objectives By the end of this lecture you should be able to:  use the JTabbedPane.
Object Oriented Programming.  Interface  Event Handling.
Agenda Introduction. Event Model. Creating GUI Application. Event Examples.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 – Graphical User Interfaces Java Foundations: Introduction to Programming.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
Creating User Interfaces Event-Driven Programming.
Chapter 10 Exceptions 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All rights reserved.
Lecture 18: Events; Cool Applets Yoni Fridman 7/30/01 7/30/01.
Oct 091 Example Program DemoInputValidation1.java DemoInputValidation2.java.
1/18H212Mouse and Timer Events H212 Introduction to Software Systems Honors Lecture #16: Mouse and Timer Events October 26, 2015.
Polygons and Polylines © 2004 Pearson Addison-Wesley. All rights reserved 7-1 Arrays can be helpful in graphics processing For example, they can be used.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
Chapter 5: Enhancing Classes Presentation slides for Java Software Solutions Foundations of Program Design Second Edition by John Lewis and William Loftus.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Fundamentals of Windows Mouse n 4 Basic Operations: –Pointing –Clicking –Double Clicking –Dragging.
Dive Into® Visual Basic 2010 Express
Microsoft Visual Basic 2005: Reloaded Second Edition
Chapter 9: Graphical User Interfaces
PowerPoint Essentials Vocabulary
Responding to Events Event Handling in Java
Human Computer Interaction Lecture 07 The Interaction
Chapter 1: An Introduction to Visual Basic 2015
Advanced User Interfaces
Chapter 2 – Introduction to the Visual Studio .NET IDE
An Introduction to Computers and Visual Basic
Processing Timer Events
10 Exceptions Software Solutions Lewis & Loftus java 5TH EDITION
Program and Graphical User Interface Design
Chapter 1: An Introduction to Visual Basic 2015
An Introduction to Computers and Visual Basic
Programming in Java Event Handling
GUI Event Handling Nithya Raman.
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Exploring the Basics of Windows XP
Program and Graphical User Interface Design
Introduction to Microsoft Windows
Timer class and inner classes
Exploring the Basics of Windows XP
An Introduction to Computers and Visual Basic
Chapter 6: Arrays and Vectors
Presentation transcript:

ITEC220 GUI Lecture – Part 2 References Java Software Solutions,” by Lewis & Loftus Chapter 7 Chapter 8 Chapter 9 Java Foundations-Introduction to Program Design & Data Structures,” by Lewis, DePasquale, and Chase Chapter 6

Chapter 7 References Java Software Solutions,” by Lewis & Loftus Java Foundations-Introduction to Program Design & Data Structures,” by Lewis, DePasquale, and Chase Chapter 6 Arrays

Outline Mouse Events and Key Events © 2004 Pearson Addison-Wesley. All rights reserved

Mouse Events Events related to the mouse are separated into mouse events and mouse motion events Mouse Events: mouse pressed the mouse button is pressed down mouse released the mouse button is released mouse clicked the mouse button is pressed down and released without moving the mouse in between mouse entered the mouse pointer is moved onto (over) a component mouse exited the mouse pointer is moved off of a component © 2004 Pearson Addison-Wesley. All rights reserved

Mouse Events Mouse Motion Events: mouse moved the mouse is moved mouse dragged the mouse is moved while the mouse button is pressed down Listeners for mouse events are created using the MouseListener and MouseMotionListener interfaces A MouseEvent object is passed to the appropriate method when a mouse event occurs © 2004 Pearson Addison-Wesley. All rights reserved

Mouse Events For a given program, we may only care about one or two mouse events To satisfy the implementation of a listener interface, empty methods must be provided for unused events See Dots.java (page 413) See DotsPanel.java (page 414) © 2004 Pearson Addison-Wesley. All rights reserved

Mouse Events Rubberbanding is the visual effect in which a shape is "stretched" as it is drawn using the mouse The following example continually redraws a line as the mouse is dragged See RubberLines.java (page 417) See RubberLinesPanel.java (page 418) © 2004 Pearson Addison-Wesley. All rights reserved

Key Events A key event is generated when the user types on the keyboard key pressed a key on the keyboard is pressed down key released a key on the keyboard is released key typed a key on the keyboard is pressed down and released Listeners for key events are created by implementing the KeyListener interface A KeyEvent object is passed to the appropriate method when a key event occurs © 2004 Pearson Addison-Wesley. All rights reserved

Key Events The component that generates a key event is the one that has the current keyboard focus Constants in the KeyEvent class can be used to determine which key was pressed The following example "moves" an image of an arrow as the user types the keyboard arrow keys See Direction.java (page 421) See DirectionPanel.java (page 422) © 2004 Pearson Addison-Wesley. All rights reserved

Chapter 8 References Java Software Solutions,” by Lewis & Loftus Java Foundations-Introduction to Program Design & Data Structures,” by Lewis, DePasquale, and Chase Chapter 6 Inheritance

Outline The Timer Class © 2004 Pearson Addison-Wesley. All rights reserved

The Timer Class The Timer class of the javax.swing package is a GUI component, but it has no visual representation A Timer object generates an action event at specified intervals Timers can be used to manage any events that are based on a timed interval, such as an animation To create the illusion of movement, we use a timer to change the scene after an appropriate delay © 2004 Pearson Addison-Wesley. All rights reserved

The Timer Class The start and stop methods of the Timer class start and stop the timer The delay can be set using the Timer constructor or using the setDelay method See Rebound.java (page 471) See ReboundPanel.java (page 472) © 2004 Pearson Addison-Wesley. All rights reserved

Chapter 9 References Java Software Solutions,” by Lewis & Loftus Java Foundations-Introduction to Program Design & Data Structures,” by Lewis, DePasquale, and Chase Chapter 6 Polymorphism

Outline File Choosers and Color Choosers © 2004 Pearson Addison-Wesley. All rights reserved

Dialog Boxes Recall that a dialog box is a small window that "pops up" to interact with the user for a brief, specific purpose The JOptionPane class makes it easy to create dialog boxes for presenting information, confirming an action, or accepting an input value Let's now look at two other classes that let us create specialized dialog boxes © 2004 Pearson Addison-Wesley. All rights reserved

File Choosers Situations often arise where we want the user to select a file stored on a disk drive, usually so that its contents can be read and processed A file chooser, represented by the JFileChooser class, simplifies this process The user can browse the disk and filter the file types displayed See DisplayFile.java (page 516) © 2004 Pearson Addison-Wesley. All rights reserved

Color Choosers In many situations we want to allow the user to select a color A color chooser , represented by the JColorChooser class, simplifies this process The user can choose a color from a palette or specify the color using RGB values See DisplayColor.java (page 519) © 2004 Pearson Addison-Wesley. All rights reserved

Graphical User Interfaces Chapter 6 References Java Software Solutions,” by Lewis & Loftus Chapter 7 Chapter 8 Chapter 9 Java Foundations-Introduction to Program Design & Data Structures,” by Lewis, DePasquale, and Chase Chapter 6 Graphical User Interfaces

6.6 – Tool Tips A tool tip is a short line of text that appears over a component when the mouse cursor is rested momentarily on top of the component Tool tips usually inform the user about the component Tool tips can be assigned by using the setToolTipText method of a component JButton button = new Button (“Compute”); button.setToolTipText (“Calculates the area under the curve”); © 2004 Pearson Addison-Wesley. All rights reserved

Mnemonic character ‘f’ set for the Off button 6.6 – Mnemonics (1) A mnemonic is a character that allows the user to push a button or make a menu choice using the keyboard in addition to the mouse For example, when a mnemonic has been defined for a button, the user can hold down the Alt key and press the mnemonic character to activate (depress) the button Mnemonic character ‘f’ set for the Off button © 2004 Pearson Addison-Wesley. All rights reserved

Mnemonic character ‘f’ set for the Off button 6.6 – Mnemonics (2) We set the mnemonic for a component using the setMnemonic method of the component Once set, a character in the label will be underlined to indicate that it can be used as a shortcut JButton button = new Button (“Off”); button.setMnemonic (“f”); Mnemonic character ‘f’ set for the Off button © 2004 Pearson Addison-Wesley. All rights reserved