Java Reference
In-Depth Information
button, the button's label is changed to
Resume
, as shown in Figure 16.45c. The
Clear
button resets the count to 0 and resets the button's label to
Start
.
(a)
(b)
(c)
(d)
F
IGURE
16.45
(a-c) The program counts up the time. (d) The program counts down the time.
*16.21
(
Count-down stopwatch
) Write a program that allows the user to enter time in
seconds in the text field and press the
Enter
key to count down the seconds,
as shown in Figure 16.45d. The remaining seconds are redisplayed every
one second. When the seconds are expired, the program starts to play music
continuously.
16.22
(
Play, loop, and stop a sound clip
) Write a program that meets the following
requirements:
Get an audio file from the class directory using
AudioClip
.
■
Place three buttons labeled
Play
,
Loop
, and
Stop
, as shown in Figure 16.46a.
■
If you click the
Play
button, the audio file is played once. If you click the
Loop
button, the audio file keeps playing repeatedly. If you click the
Stop
button, the playing stops.
■
(a)
(b)
F
IGURE
16.46
(a) Click
Play
to play an audio clip once, click
Loop
to play an audio repeatedly, and click
Stop
to termi-
nate playing. (b) The program lets the user specify image files, an audio file, and the animation speed.
Search WWH ::
Custom Search