 2002 Prentice Hall, Inc. All rights reserved. 12.1 Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides.

Slides:



Advertisements
Similar presentations
1 Graphical User Interface (GUI) Applications Abstract Windowing Toolkit (AWT) Events Handling Applets.
Advertisements

Graphic User Interfaces Layout Managers Event Handling.
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
Java Swing Recitation – 11/(20,21)/2008 CS 180 Department of Computer Science, Purdue University.
1 Chapter 7 Graphics and Event Handling. 2 Overview The java.awt and javax.swing packages and their subpackages support graphics and event handling. Many.
Event Handling Events and Listeners Timers and Animation.
10.1 AWT The AWT classes Users today expect a Graphical User Interface (GUI) Improves application usability Difficult to implement cross-platform.
Graphical User Interface Components: Part 1
GUI Programming in Java Tim McKenna GUI Programming Concepts l conventional programming: sequence of operations is determined by the program.
A.k.a. GUI’s.  If you want to discuss your Lab 2 grade come see me this week. ◦ Office: 436 ERB. One hour prior to class ◦ Open to Appointments MWF 
GUI Programming in Java
Java Programming Chapter 10 Graphical User Interfaces.
Welcome to CIS 083 ! Events CIS 068.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
CIS 068 Welcome to CIS 083 ! Introduction to GUIs: JAVA Swing.
Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal
MIT AITI 2003 Lecture 17. Swing - Part II. The Java Event Model Up until now, we have focused on GUI's to present information (with one exception) Up.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Java GUI’s are event driven, meaning they generate events when the user interacts with the program. Typical events are moving the mouse, clicking a mouse.
Dale Roberts GUI Programming using Java - Event Handling Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Dale Roberts GUI Programming using Java - Introduction Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Graphical User Interface Components: Part 1 Chapter 11.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
1 Outline 1 Introduction 2 Overview of Swing Components 3 JLabel 4 Event Handling 5 TextFields 6 How Event Handling Works 7 JButton 8 JCheckBox and JRadioButton.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
1 Unit 5 GUI Aum Amriteshwaryai Namah. 2 Overview Shall learn how to reuse the graphics classes provided by Java for constructing Graphical User Interface.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
Timer class and inner classes. Processing timer events Timer is part of javax.swing helps manage activity over time Use it to set up a timer to generate.
Layout Managers Arranges and lays out the GUI components on a container.
Omer Boyaci.  GUIs are event driven.  When the user interacts with a GUI component, the interaction—known as an event—drives the program to perform.
Computer Science [3] Java Programming II - Laboratory Course Lab 4: Common GUI Event Types and Listener Interfaces Layout Mangers Faculty of Engineering.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
AGDER COLLEGEFACULTY OF ENGINEERING & SCIENCE GUI Components ikt403 – Object-Oriented Software Development.
Software Design 5.1 From Using to Programming GUIs l Extend model of "keep it simple" in code to GUI  Bells and whistles ok, but easy to use and hide.
Event Handling. 2 GUIs are event driven –Generate events when user interacts with GUI e.g., moving mouse, pressing button, typing in text field, etc.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Week 6: Basic GUI Programming Concepts in Java Example: JFrameDemo.java container : a screen window/applet window/panel that groups and arranges components.
Object Oriented Programming.  Interface  Event Handling.
Graphical User Interface Components: Part 1 Chapter 11.
Basics of GUI Programming Chapter 11 and Chapter 22.
Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along.
 Many event-listener interfaces contain multiple methods.  An adapter class implements an interface and provides a default implementation (with an empty.
1 Layout Managers Layout managers –Provided for arranging GUI components –Provide basic layout capabilities –Processes layout details –Programmer can concentrate.
 Figure illustrates a hierarchy containing many event classes from the package java.awt.event.  Used with both AWT and Swing components.  Additional.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
1 Lecture 8: User Interface Components with Swing.
Jozef Goetz Credits: Copyright  Pearson Education, Inc. All rights reserved. expanded by J. Goetz, 2016.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
1 A Quick Java Swing Tutorial. 2 Introduction Swing – A set of GUI classes –Part of the Java's standard library –Much better than the previous library:
Lecture 6 Object Oriented Programming Using Java By Rashid Ahmad Department of Computer Science University of Peshawar.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
© Copyright by Pearson Education, Inc. All Rights Reserved. Appendix I GUI Components and Event Handling Android How to Program, 3/e.
GUI Programming using Java - Event Handling
Graphical User Interfaces
CompSci 230 S Programming Techniques
Aum Amriteshwaryai Namah
Appendix I GUI Components and Event Handling
A Quick Java Swing Tutorial
Graphical User Interface (GUI) Components: Part 1 Java How to Program, 9 th Edition Chapter 14.
Ellen Walker Hiram College
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Timer class and inner classes
Introduction to Computing Using Java
IFS410: Advanced Analysis and Design
A Quick Java Swing Tutorial
Graphical User Interface
Presentation transcript:

 2002 Prentice Hall, Inc. All rights reserved Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides users with basic level of familiarity –Built from GUI components (controls, widgets, etc.) User interacts with GUI component via mouse, keyboard, etc.

 2002 Prentice Hall, Inc. All rights reserved. Fig Some basic GUI components.

 2002 Prentice Hall, Inc. All rights reserved Swing Overview Swing GUI components –Package javax.swing –Components originate from AWT (package java.awt ) –Contain look and feel Appearance and how users interact with program –Lightweight components Written completely in Java

 2002 Prentice Hall, Inc. All rights reserved Swing Overview (cont.) Class Component –Contains method paint for drawing Component onscreen Class Container –Collection of related components –Contains method add for adding components Class JComponent –Pluggable look and feel for customizing look and feel –Shortcut keys (mnemonics) –Common event-handling capabilities

 2002 Prentice Hall, Inc. All rights reserved. Fig Common superclasses of many of the Swing components.

 2002 Prentice Hall, Inc. All rights reserved Event-Handling Model GUIs are event driven –Generate events when user interacts with GUI e.g., moving mouse, pressing button, typing in text field, etc. Class java.awt.AWTEvent

 2002 Prentice Hall, Inc. All rights reserved. Fig Some event classes of package java.awt.event

 2002 Prentice Hall, Inc. All rights reserved Event-Handling Model (cont.) Event-handling model –Three parts Event source –GUI component with which user interacts Event object –Encapsulates information about event that occurred Event listener –Receives event object when notified, then responds –Programmer must perform two tasks Register event listener for event source Implement event-handling method (event handler)

 2002 Prentice Hall, Inc. All rights reserved. Fig Event-listener interfaces of package java.awt.event

 2002 Prentice Hall, Inc. All rights reserved How Event Handling Works Two open questions from Section 12.4 –How did event handler get registered? Answer: –Through component’s method addActionListener –Lines of TextFieldTest.java –How does component know to call actionPerformed ? Answer: –Event is dispatched only to listeners of appropriate type –Each event type has corresponding event-listener interface Event ID specifies event type that occurred

 2002 Prentice Hall, Inc. All rights reserved. Fig 12.8 Event registration for JTextField textField1.

 2002 Prentice Hall, Inc. All rights reserved Mouse Event Handling Event-listener interfaces for mouse events –MouseListener –MouseMotionListener –Listen for MouseEvent s

 2002 Prentice Hall, Inc. All rights reserved. Fig MouseListener and MouseMotionListener interface methods

 2002 Prentice Hall, Inc. All rights reserved Adapter Classes Adapter class –Implements interface –Provides default implementation of each interface method –Used when all methods in interface is not needed

 2002 Prentice Hall, Inc. All rights reserved. Fig Event adapter classes and the interfaces they implement.

 2002 Prentice Hall, Inc. All rights reserved Layout Managers Layout managers –Provided for arranging GUI components –Provide basic layout capabilities –Processes layout details –Programmer can concentrate on basic “look and feel” –Interface LayoutManager

 2002 Prentice Hall, Inc. All rights reserved. Fig Layout managers.

 2002 Prentice Hall, Inc. All rights reserved FlowLayout FlowLayout –Most basic layout manager –GUI components placed in container from left to right

 2002 Prentice Hall, Inc. All rights reserved BorderLayout BorderLayout –Arranges components into five regions NORTH (top of container) SOUTH (bottom of container) EAST (left of container) WEST (right of container) CENTER (center of container)

 2002 Prentice Hall, Inc. All rights reserved Panels Panel –Helps organize components –Class JPanel is JComponent subclass –May have components (and other panels) added to them