import java.applet.Applet; import java.awt.*; public class AnimationOneThread extends Applet implements Runnable { //---------------------------------------------------- /** Sequence through an array of 15 images. * A thread controls the image index to display. * Overrides update to avoid flicker problems. */ private static final int numImages = 15; private Image[] images; private int index; private Thread Duke = null; public void init() { // load images images = new Image[ numImages ]; for (int i=0; i= numImages ) index = 0; repaint(); try { Thread.sleep(100); } catch (InterruptedException e) { break; } // break while loop } } //---------------------------------------------------- /** When the Applet's stop method will be called Duke * will be set to null as a flag to stop the while * loop in run method. */ public void stop() { if (Duke != null) { Duke = null; } } }