Java Reference
In-Depth Information
**16.23
( Create an image animator with audio ) Create animation in Figure  16.46b to
meet the following requirements:
Allow the user to specify the animation speed in a text field.
Get the number of iamges and image's file-name prefix from the user. For
example, if the user enters n for the number of images and L for the image
prefix, then the files are L1.gif , L2.gif , and so on, to L n .gif . Assume that the
images are stored in the image directory, a subdirectory of the program's
class directory. The animation displays the images one after the other.
Allow the user to specify an audio file URL. The audio is played while the
animation runs.
**16.24
( Revise Listing 16.14 MediaDemo.java ) Add a slider to enable the user to set the
current time for the video and a label to display the current time and the total
time for the video. As shown in Figure 16.47a, the total time is 5 minutes and 3
seconds and the current time is 3 minutes and 58 seconds. As the video plays, the
slider value and current time are continuously updated.
(a)
(b)
F IGURE 16.47
(a) A slider for current video time and a label to show the current time and total time are added. (b) You
can set the speed for each car.
**16.25 ( Racing cars ) Write a program that simulates four cars racing, as shown in
Figure 16.47b. You can set the speed for each car, with maximum 100.
**16.26 ( Simulation: raise flag and play anthem ) Write a program that displays a flag
rising up, as shown in Figure 15.14. As the national flag rises, play the national
anthem. (You may use a flag image and anthem audio file from Listing 16.15.)
Comprehensive
**16.27
( Display country flag and flag description ) Listing 16.4, ComboBoxDemo.java,
gives a program that lets the user view a country's flag image and description
by selecting the country from a combo box. The description is a string coded
in the program. Rewrite the program to read the text description from a file.
Suppose that the descriptions are stored in the files description0.txt , . . . , and
 
Search WWH ::




Custom Search