Java Reference
In-Depth Information
Sections 17.6-17.8
**17.15
(
Use
JScrollBar
) Write a program that uses scroll bars to select the fore-
ground color for a label, as shown in Figure 17.29. Three horizontal scroll bars
are used for selecting the color's red, green, and blue components. Use a title
border on the panel that holds the scroll bars.
Panel with
BorderLayout
Panel with
GridLayout
for three labels
Panel with
GridLayout
for three scroll bars
F
IGURE
17.29
The foreground color changes in the label as you adjust the scroll bars.
**17.16
(
Use
JSlider
) Revise the preceding exercise using sliders.
***17.17
(
Display a calendar
) Write a program that displays the calendar for the current
month. You can use the
Prior
and
Next
buttons to show the calendar of the pre-
vious or next month. Display the dates in the current month in black and dis-
play the dates in the previous month and next month in gray, as shown in
Figure 17.30.
JLabel
JPanel
with
GridLayout
Each cell is
a
JLabel
F
IGURE
17.30
The program displays the calendar for the current month.
*17.18
(
Revise Listing 17.8, MultipleWindowsDemo.java
) Instead of displaying the
occurrences of the letters using the
Histogram
component in Listing 17.8,
use a bar chart, so that the display is as shown in Figure 17.31.
F
IGURE
17.31
The number of occurrences of each letter is displayed in a bar chart.