//******************************************************************** // Rebound.java Author: Lewis/Loftus // // Demonstrates an animation and the use of the Timer class. //******************************************************************** import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Rebound extends JApplet { private final int DELAY = 20; private Timer timer; //----------------------------------------------------------------- // Sets up the applet, including the timer for the animation. //----------------------------------------------------------------- public void init() { timer = new Timer (DELAY, null); getContentPane().add (new ReboundPanel(timer)); } //----------------------------------------------------------------- // Starts the animation when the applet is started. //----------------------------------------------------------------- public void start () { timer.start(); } //----------------------------------------------------------------- // Stops the animation when the applet is stopped. //----------------------------------------------------------------- public void stop () { timer.stop(); } }