import java.awt.*;

public class Animator 
    implements Runnable {  
  public Animator(Component comp) {
    this.comp = comp; 
  } 
  
  final public void setDelay(int delay) {
    this.delay = delay; 
  }
  
  final public int getDelay() {
    return delay; 
  }
  public void start() {
	System.err.println("thread start called");
    animationThread = new Thread(this);
    animationThread.start();
  }
    
  public void stop() {
	System.err.println("thread stop called");
    animationThread = null; 
  }
  
  public void run() {
    while (Thread.currentThread() == animationThread) {
      System.err.println("thread run called");
      try { 
        Thread.sleep(delay); 
      } catch (InterruptedException e){}     
      comp.repaint();
    }
  }
  
  protected Component comp; 
  /** The interval between two consecutive frames 
      in milliseconds */
  protected int delay = 100;     
  /** The animation thread */ 
  protected Thread animationThread;
  
}
