Chapter6 Notes

Chapter6 Notes - 1 Graphical User Interfaces Many programs...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Graphical User Interfaces Many programs provide graphical user interfaces (GUI) through which a user interacts Chapter 6 focuses on discussing the core elements: components, events, and listeners discussing the concept of a layout manager examining mouse and keyboard events describing tool tips and mnemonics discussing GUI design issues Outline GUI Elements More Components Layout Managers Mouse and Key Events Dialog Boxes Important Details GUI Design 2 6.1 GUI Elements Examples from previous chapters are known as command-line applications , which interact with the user through simple prompts and feedback Command-line applications lack the rich user experience With GUI, the user is not limited to responding to prompts in a particular order and receiving feedback in one place 6.1 GUI Elements Three kinds of objects are needed to create a GUI in Java components events listeners Component an object that defines a screen element used to display information or allow the user to interact with the program A container is a special type of component that is used to hold and organize other components 3 6.1 GUI Elements Event an object that represents some occurrence in which we may be interested Often correspond to user actions (mouse button press, keyboard key press) Most GUI components generate events to indicate a user action related to that component Program that is oriented around GUI, responding to user events is called event-driven 6.1 GUI Elements Listener an object that waits for an event to occur and responds in way when it does In designing a GUI-based program we need to establish the relationships between the listener, the event it listens for, and the component that generates the event Use existing components and events from the Java class library. But write our own listener classes to perform whatever actions we desire when events occur 4 6.1 GUI Elements To create a Java program that uses a GUI, we must: instantiate and set up the necessary components, implement listener classes that define what happens when particular events occur, and establish the relationship between the listeners and the components that generate the events of interest Java components and other GUI-related classes are defined primarily in two packages java.awt javax.swing 6.1 GUI Elements The Abstract Window Toolkit (AWT) was the original Java GUI package contains many important classes we will use The Swing package was added later provides components that are more versatile than those of AWT Lets look at a simple example that contains all of the basic GUI elements the example presents the user with a single push button each time the button is pushed, a counter is updated and displayed 5 6.1 PushCounter.java //******************************************************************** // PushCounter.javaPushCounter....
View Full Document

Page1 / 50

Chapter6 Notes - 1 Graphical User Interfaces Many programs...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online