Java Reference
In-Depth Information
**15.25
( Animation: ball on curve ) Write a program that animates a ball moving along
a sine curve, as shown in Figure 15.32. When the ball gets to the right border,
it starts over from the left. Enable the user to resume/pause the animation with
a click on the left/right mouse button.
F IGURE 15.32
The program animates a ball traveling along a sine curve.
*15.26
( Change opacity ) Rewrite Programming Exercise 15.24 so that the ball's
opacity is changed as it swings.
*15.27
( Control a moving text ) Write a program that displays a moving text, as shown
in Figure 15.33a and b. The text moves from left to right circularly. When it
disappears in the right, it reappears from the left. The text freezes when the
mouse is pressed and moves again when the button is released.
(a)
(b)
(c)
F IGURE 15.33
(a and b) A text is moving from left to right circularly. (c) The program simulates a fan running.
**15.28
( Display a running fan ) Write a program that displays a running fan, as shown
in Figure 15.33c. Use the Pause , Resume , Reverse buttons to pause, resume,
and reverse fan running.
VideoNote
Display a running fan
**15.29
( Racing car ) Write a program that simulates car racing, as shown in
Figure 15.34a. The car moves from left to right. When it hits the right end, it
restarts from the left and continues the same process. You can use a timer to
control animation. Redraw the car with a new base coordinates ( x , y ), as shown
in Figure  15.34b. Also let the user pause/resume the animation with a but-
ton press/release and increase/decrease the car speed by pressing the UP and
DOWN arrow keys.
**15.30
( Slide show ) Twenty-five slides are stored as image files ( slide0.jpg , slide1
.jpg , . . . , slide24.jpg ) in the image directory downloadable along with the
source code in the topic. The size of each image is 800
600. Write a pro-
gram that automatically displays the slides repeatedly. Each slide is shown for
*
 
Search WWH ::




Custom Search