import java.awt.*;
import java.applet.*;
import java.util.Random;

/**
 * A simple framework for an applet that does animation.
 * 
 * @author Samuel A. Rebelsky
 * @version 1.1 of March 1999
 */
public class AnimationApplet 
  extends Applet 
  implements Runnable {

  // +--------+--------------------------------------------------
  // | Fields |
  // +--------+

  /** The thread corresponding to the current applet.  */
  protected Thread thread;


  // +-------------------------+---------------------------------
  // | Standard Applet Methods |
  // +-------------------------+

  /**
   * Initialize the applet.  
   */
  public void init() {
  } // init()
  
  /**
   * Paint the current "animation frame" on the screen.
   */
  public void paint(Graphics g) {
  } // paint(Graphics)

  /**
   * Run the thread.
   */
  public void run() {
    // It appears that we keep going forever.  However, external
    // things (that is, the web browser) control when we stop.
    while (true) {
      try {
        thread.sleep(50);
      }
      catch (InterruptedException ie) {
        // Do nothing
      }
      // Update information for the animation
      updateInformation();
      // And repaint
      repaint();
    } // while
  } // run()

  /**
   * Start the thread.
   */
  public void start() {
    thread = new Thread(this);
    thread.setPriority(Thread.MIN_PRIORITY);
    thread.start();
  } // start()

  /**
   * Stop the thread.
   */
  public void stop() {
    thread.stop();
  } // stop()

  // +-------------------------+---------------------------------
  // | Standard Applet Methods |
  // +-------------------------+

   /**
    * Update information to support the next "frame" in the
    * animation.
    */
   public void updateInformation() {
   } // updateInformation()
} // AnimationApplet

