Java Reference
In-Depth Information
Sample GUI: The
SwingSet3
Demo Application
As an example of a GUI, consider Fig. 12.1, which shows the
SwingSet3
demo application
from the JDK demos and samples download at
http://www.oracle.com/technetwork/
java/javase/downloads/index.html
.
This application is a nice way for you to browse
through the various GUI components provided by Java's Swing GUI APIs. Simply click a
component name (e.g.,
JFrame
,
JTabbedPane
, etc.) in the
GUI Components
area at the left
of the window to see a demonstration of the GUI component in the right side of the win-
dow. The source code for each demo is shown in the text area at the bottom of the win-
dow. We've labeled a few of the GUI components in the application. At the top of the
window is a
title bar
that contains the window's title. Below that is a
menu bar
containing
menus
(
File
and
View
). In the top-right region of the window is a set of
buttons
—typi-
cally, users click buttons to perform tasks. In the
GUI Components
area of the window is a
combo box
; the user can click the down arrow at the right side of the box to select from a
list of items. The menus, buttons and combo box are part of the application's GUI. They
enable you to interact with the application.
me
n
u
title bar
menu bar
comb
o
box
text
a
rea
but
t
on
scrol
l
bar
Fig. 12.1
|
SwingSet3
application demonstrates many of Java's Swing GUI components.
A GUI's look consists of its visual aspects, such as its colors and fonts, and its feel consists
of the components you use to interact with the GUI, such as buttons and menus. Together