Java Reference
In-Depth Information
12.1 Introduction
12.2 Java's Nimbus Look-and-Feel
12.3 Simple GUI-Based Input/Output with
JOptionPane
12.4 Overview of Swing Components
12.5 Displaying Text and Images in a
Window
12.6 Text Fields and an Introduction to
Event Handling with Nested Classes
12.7 Common GUI Event Types and
Listener Interfaces
12.8 How Event Handling Works
12.9 JButton
12.10 Buttons That Maintain State
12.10.1 JCheckBox
12.10.2 JRadioButton
12.11 JComboBox ; Using an Anonymous
Inner Class for Event Handling
12.12 JList
12.13 Multiple-Selection Lists
12.14 Mouse Event Handling
12.15 Adapter Classes
12.16 JPanel Subclass for Drawing with
the Mouse
12.17 Key Event Handling
12.18 Introduction to Layout Managers
12.18.1 FlowLayout
12.18.2 BorderLayout
12.18.3 GridLayout
12.19 Using Panels to Manage More
Complex Layouts
12.20 JTextArea
12.21 Wrap-Up
Summary | Self-Review Exercises | Answers to Self-Review Exercises | Exercises | Making a Difference
12.1 Introduction
A graphical user interface ( GUI ) presents a user-friendly mechanism for interacting with
an application. A GUI (pronounced “GOO-ee”) gives an application a distinctive “look-
and-feel.” GUIs are built from GUI components . These are sometimes called controls or
widgets —short for window gadgets. A GUI component is an object with which the user
interacts via the mouse, the keyboard or another form of input, such as voice recognition.
In this chapter and Chapter 22, GUI Components: Part 2, you'll learn about many of
Java's so-called Swing GUI components from the javax.swing package. We cover other
GUI components as they're needed throughout the topic. In Chapter 25 and two online
chapters, you'll learn about JavaFX—Java's latest APIs for GUI, graphics and multimedia.
Look-and-Feel Observation 12.1
Providing different applications with consistent, intuitive user-interface components gives
users a sense of familiarity with a new application, so that they can learn it more quickly
and use it more productively.
IDE Support for GUI Design
Many IDEs provide GUI design tools with which you can specify a component's size , lo-
cation and other attributes in a visual manner by using the mouse, the keyboard and drag-
and-drop. The IDEs generate the GUI code for you. This greatly simplifies creating GUIs,
but each IDE generates this code differently. For this reason, we wrote the GUI code by
hand, as you'll see in the source-code files for this chapter's examples. We encourage you
to build each GUI visually using your preferred IDE(s).
 
 
Search WWH ::




Custom Search