import java.awt.Graphics;
import java.awt.Image;
import java.applet.Applet;

public class AnalogousClock extends Applet implements Runnable {
	static Image images[];
	static int counter=0;
   Thread animator;

   public void init() {
		images = new Image[12];
      for (int i=0;i<images.length;i++)
      	images[i] = getImage( getDocumentBase(), "clock-"+i+".gif");
	} //init()

   public void start() {
   	while ( images[0].getWidth(this) == -1 || images[0].getHeight(this) == -1)
   		;
   	this.resize( images[0].getWidth(this) , images[0].getHeight(this) );
   	animator = new Thread (this);
		animator.setPriority(Thread.MIN_PRIORITY);
      animator.start ();
   } //start()

	public void stop() {
		animator = null;
	} //stop()

   public void run () {
		while (true) {
			try {
	      	Thread.sleep(200);
	      } //try
	      catch (InterruptedException ie) {
				//ignore it
	      } //catch

			repaint();
	      if (++counter==images.length)
	         counter=0;
		} //while
   } //run()

   public void paint (Graphics g) {
   	System.out.println("drawing image: clock-"+counter+".gif");
   	g.drawImage (images[counter], 0, 0, this);
   } //paint()
} //class AnalogousClock