import java.applet.*; import java.awt.*; // Extend this applet to write a simple animation. public abstract class BasicAnimationApplet extends DoubleBufferApplet implements Runnable { Thread t; int sleepMillis = 40; public void start() { t = new Thread(this); t.start(); } public void stop() { t = null; } public void run() { while (Thread.currentThread() == t) { step(); repaint(); try { Thread.sleep(sleepMillis); } catch (InterruptedException e) { return; } } } abstract void step(); public abstract void paint(Graphics g); }