Java Reference
In-Depth Information
xx 20 x 40
y 30
y 20
y 10
y
(x, y)
(a)
(b)
F IGURE 15.34
(a) The program displays a moving car. (b) You can redraw a car with a new base point.
two seconds. The slides are displayed in order. When the last slide finishes, the
first slide is redisplayed, and so on. Click to pause if the animation is currently
playing. Click to resume if the animation is currently paused.
**15.31
( Geometry: pendulum ) Write a program that animates a pendulum swinging,
as shown in Figure 15.35. Press the UP arrow key to increase the speed and the
DOWN key to decrease it. Press the S key to stop animation and the R key to
resume it.
F IGURE 15.35
Exercise 15.31 animates a pendulum swinging.
*15.32
( Control a clock ) Modify Listing 14.21, ClockPane.java, to add the animation
into this class and add two methods start() and stop() to start and stop the
clock. Write a program that lets the user control the clock with the Start and
Stop buttons, as shown in Figure 15.36a.
(a)
(b)
(c)
F IGURE 15.36
(a) Exercise 15.32 allows the user to start and stop a clock. (b and c) The
balls are dropped into the bean machine.
 
Search WWH ::




Custom Search