import java.awt.*; import java.lang.String; import java.lang.System; import java.io.PrintStream; import java.applet.Applet; import java.util.*; public class sm extends Applet implements Runnable { long PAUSE_TIME = 1000; final int numimgs = 20; Image img[] = new Image[numimgs]; Image cover_image; int index=0; boolean stopped = false; boolean loading=false; boolean loaded=false; boolean first_loaded; MediaTracker tracker; Thread animator; String image_file; String loading_message = new String("Please be patient while the images are loaded...."); public void init() { cover_image = this.getImage(this.getDocumentBase(), "cart.gif"); Panel bottomPanel = new Panel(); setLayout(new BorderLayout()); bottomPanel.add(new Button("Start")); bottomPanel.add(new Button("Stop")); add("South", bottomPanel); resize(358,463); } public void start() { animator = new Thread(this); } public void run() { int j; // When this thread is first executed, tell the user to be patient while the // images for the animation are being loaded loading = true; repaint(); tracker = new MediaTracker(this); for(j=0; j 40) index = 0; } } else { g.drawImage(cover_image, 10, 10, this); } } /** Override the update method to reduce flicker. */ public void update(Graphics g) { if (first_loaded) { super.update(g); first_loaded = false; } else { g.setColor(getForeground()); paint(g); } } }