Dr. M. Halfpap
public void init() // user code begin {1} g = getGraphics(); MediaTracker bildWaerter = new MediaTracker(this); bild1 = getImage(getCodeBase(),"sun.jpg"); bild2 = getImage(getCodeBase(),"sun2.jpg"); bild3 = getImage(getCodeBase(),"sun3.jpg"); bild4 = getImage(getCodeBase(),"sun4.jpg"); bildWaerter.addImage(bild1,0); bildWaerter.addImage(bild2,0); bildWaerter.addImage(bild3,0); bildWaerter.addImage(bild4,0); try {bildWaerter.waitForAll(); } catch (InterruptedException e) {}; bild = null; // user code end public void paint(Graphics g) { g.clearRect(100,50,100,100); //super.paint(g); if (bild != null) {g.drawImage(bild, 100, 50, 100, 100, this);} } public void run() { zeichne(); } public void stop() { thread = null; } public void zeichne() { do { bild = bild1; paint(g); try { Thread.sleep(100); } catch (InterruptedException e) {} bild = bild2; paint(g); try { Thread.sleep(100); } catch (InterruptedException e) {} bild = bild3; paint(g); try { Thread.sleep(100); } catch (InterruptedException e) {} bild = bild4; paint(g); try { Thread.sleep(100); } catch (InterruptedException e) {} } while (thread != null); }