import java.applet.*;
import java.awt.*;

public class main extends Applet implements Runnable {

	final int 			W	 			= 320,
						H 				= 240,
						IMAGECOUNT		= 51;
	Image				images[]			= null;
	MediaTracker		mt				= null;
	Thread 				th				= null;
	
	int 				currentIndex	= 0;
	
	public void init()
	{
		this.setBackground(Color.WHITE);
		this.setSize(W,H);
		
		images = new Image[IMAGECOUNT];
		mt = new MediaTracker(this);	
		
		for (int i=0; i < IMAGECOUNT; i++)
		{
			images[i] = this.getImage(this.getCodeBase(),"seq/img"+i+".jpg");		
			mt.addImage(images[i],i);
		}
	}	
	
	public void start()
	{
		th = new Thread(this);
		th.start();
	}
	
	public void run()
	{
		try {
			mt.waitForAll();
		} catch (InterruptedException ie) {
			System.err.println("MediaTracker : Interrupted!");
			return;
		}
				
	    while (th != null)
	    {		
	    	if (currentIndex < IMAGECOUNT-1)
	    		currentIndex ++;
	    	else
	    		currentIndex = 0;
	    	
			repaint();
			try {
				th.sleep(30);
			} catch (InterruptedException e) {}
	    }
	}
	
	public void stop()
	{
		th.stop();
		th = null;
	}
	
	public void paint (Graphics g)
	{	
		g.drawImage(images[currentIndex], 0,0, this);		
	}
}