//
import java.awt.*; public class GenericApplet extends java.applet.Applet implements Runnable { public boolean damage = true; // you can force a render public void render(Graphics g) { } // you can define how to render private Image image = null; private Thread t; private Rectangle r = new Rectangle(0, 0, 0, 0); public void start() { if (t == null) { t = new Thread(this); t.start(); } } public void stop() { if (t != null) { t.stop(); t = null; } } public void run() { try { while (true) { repaint(); t.sleep(30); } } catch(InterruptedException e){}; } public void update(Graphics g) { if (r.width != bounds().width || r.height != bounds().height) { image = createImage(bounds().width, bounds().height); r = bounds(); damage = true; } render(image.getGraphics()); damage = false; g.drawImage(image,0,0,this); } }