Java Reference
In-Depth Information
Creating the Interface
The first step in creating a GUI-based program, such as the
one for Crandall Power and Light, is to create the window. This
step involves creating a class named BillPayer that constructs
an instance of a JFrame and then sets properties for the Look
and Feel in its main() method, along with other attributes.
Because the program requires user input, the BillPayer class
uses an ActionListener.
confirm
dialog box
separator
line
FIGURE 8-6
3D Yes
button
shortcut key
underlined
The Swing Motif Look and Feel
The requirements document specifies the Swing Motif Look and Feel for the
BillPayer program. Recall that the LookAndFeel() methods offer any program
that uses Swing a choice of how windows, title bars, and other components are
displayed. The Motif Look and Feel displays a modern looking window, different
from those normally generated by Windows or UNIX. Motif interfaces display a
dark gray background color, and text boxes display as 3D, in the same dark gray
color. When the component with focus is displayed, a thin, pink border is added
around it. The text in the window is displayed in black. Window decorations in
the title bar are displayed using the system default. Dialog boxes in the Motif
Look and Feel display buttons below a separator line; the buttons are displayed
using a special 3D look and automatically display shortcut key designations.
Figure 8-6 displays a Motif confirm dialog box.
Motif is just one of several Look and Feel interfaces. Table 8-3 displays some
of the available Look and Feel formats that accompany the Java SDK.
Table 8-3
Examples of Look and Feel Formats
NAME
SETTING
SAMPLE
Ocean
javax.swing.plaf.metal.MetalLookAndFeel
version 1.5
Metal
javax.swing.plaf.metal.MetalLookAndFeel
version 1.4
Motif
com.sun.java.swing.plaf.motif
.MotifLookAndFeel
Windows
com.sun.java.swing.plaf.windows
.WindowsLookAndFeel
GTK
com.sun.java.swing.plaf.gtk.GTKLookAndFeel
Unix-based Look and Feel
Cross Platform
UIManager.getCrossPlatformLookAndFeel
Same as Metal
ClassName();
 
Search WWH ::




Custom Search