
import java.applet.Applet;
import java.awt.*;

public class ImageTracker extends Applet implements Runnable
  {
    Image[] images;
    int num_images = 4;
    Thread my_thread = null;
    MediaTracker tracker;

    public void init()
      {
	tracker = new MediaTracker(this);
	images = new Image[num_images];

	for (int i=0; i<num_images; i++)
		{
		images[i] = getImage(getCodeBase(), "./images/ANIM" + i + ".GIF");
		tracker.addImage(images[i], i);
		}
      }

    public void start()
      {
        my_thread = new Thread(this);
        my_thread.start();
      }

    public void run()
      {
	showStatus("Loading Images...");
		try {
			tracker.waitForAll();
		}
            	catch(InterruptedException e) {
              	}
		if (tracker.isErrorAny()) {
            		showStatus("Error loading images. See Ya!");
			return;
              	}
	showStatus("Done Loading Images");


	
        while(true) {
		for (int i=0; i<num_images; i++) {
	    		getGraphics().drawImage(images[i], 0, 0, this);

            		try {
                		Thread.sleep(600);
              		}
            		catch(InterruptedException e) {
              		}
		}
        }
      }

  }

