Java Reference
In-Depth Information
(a) (b)
F IGURE 18.25 (a) The applet allows you to add or remove bouncing balls. (b) Click Play to
play an audio clip once, click Loop to play an audio repeatedly, and click Stop to terminate
playing.
*18.20
( Play, loop, and stop a sound clip ) Write an applet that meets the following
requirements:
Get an audio file from the class directory.
Place three buttons labeled Play , Loop , and Stop , as shown in Figure 18.25b.
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.
The applet can run as an application.
**18.21
( Create an alarm clock ) Write an applet that will display a digital clock with a
large display panel that shows the hour, minute, and second. This clock should
allow the user to set an alarm. Figure 18.26a shows an example of such a clock.
To turn on the alarm, check the Alarm check box. To specify the alarm time,
click the Set alarm button to display a new frame, as shown in Figure 18.26b.
You can set the alarm time in the frame.
(a)
(b)
F IGURE 18.26
The program displays the current hour, minute, and second and enables you
to set an alarm.
**18.22
( Create an image animator with audio ) Create animation using the applet
shown in Figure 18.27 to meet the following requirements:
Allow the user to specify the animation speed in a text field.
Get the number of frames and the image's file-name prefix from the user.
For example, if the user enters n for the number of frames and L for the
image prefix, then the files are L1 , L2 , and so on, to L n . Assume that the
images are stored in the image directory, a subdirectory of the applet's
directory.
Allow the user to specify an audio file name. The audio file is stored in the
same directory as the applet. The sound is played while the animation runs.
Search WWH ::




Custom Search