Java Reference
In-Depth Information
*17.6
( Create a miles/kilometers converter ) Write a program that converts miles and
kilometers, as shown in Figure 17.21. If you enter a value in the Mile text field
and press the Enter key, the corresponding kilometer measurement is displayed
in the Kilometer text field. Likewise, if you enter a value in the Kilometer text
field and press the Enter key, the corresponding miles is displayed in the Mile
text field.
Panel with BorderLayout
Panel with GridLayout
for two labels
Panel with GridLayout for
two text fields
F IGURE 17.21
The program converts miles to kilometers, and vice versa.
*17.7
( Set clock time ) Write a program that displays a clock and sets the time with the
input from three text fields, as shown in Figure 17.22. Use the StillClock in
Listing 13.10.
StillClock
Panel with FlowLayout
F IGURE 17.22
The program displays the time specified in the text fields.
**17.8
( Select a font ) Write a program that can dynamically change the font of a message
to be displayed on a panel. The message can be displayed in bold and italic at the
same time, and/or it can be displayed in the center of the panel. You can select the
font name or font size from combo boxes, as shown in Figure 17.23. The available
font names can be obtained using getAvailableFontFamilyNames() in
GraphicsEnvironment (see Section 12.8, The Font Class). The combo box for
the font size is initialized with numbers from 1 to 100 .
Panel with BorderLayout
Panel with
BorderLayout
Panel with BorderLayout
F IGURE 17.23
You can dynamically set the font for the message.
 
Search WWH ::




Custom Search