![]() |
![]() ![]() die führende deutsche Java-Seite ![]() ![]() und Hannes Gamperl ![]() |
![]()
|
![]()
Java-Neuigkeiten
Einführung
Workshops
Wissen
Ressourcen
K&K Intern
Weitere Angebote
EMail an java@acc.de
|
import java.awt.*; public class Animacon extends java.applet.Applet implements Runnable { Thread thread=null; int dx, dy; int speed; int col; int i; Graphics offGraphics; Image offImage; public void init() { dx=size().width; dy=size().height; offImage=createImage(dx, dy); offGraphics=offImage.getGraphics(); offGraphics.setColor(Color.black); offGraphics.fillRect(0, 0, dx+1, dy+1); } public void start() { if(thread == null) { thread = new Thread(this); thread.start(); } } public void stop() { thread = null; offImage = null; offGraphics = null; } public void run() { while (thread != null) { try { Thread.sleep(speed); } catch (InterruptedException e) {} repaint(); } } public void paint(Graphics g) { update(g); } public void update (Graphics g) { col++; if(col>255) col=0; offGraphics.setColor(new Color(col, 0, 0)); i+=3; if(i>=dx) i=0; offGraphics.drawLine( i, 0, dx-i, dy); offGraphics.drawLine(dx-i, 0, i, dy); offGraphics.drawLine(0, i, dx, dy-i); offGraphics.drawLine(0, dy-i, dx, i); g.drawImage(offImage, 0, 0, this); } } ![]()
| |||||
Nach oben |
© 1998 Christoph Bergmann / ACCESS Internet. Alle Rechte vorbehalten. |