import javax.swing.*; import java.awt.*; import javax.swing.event.*; public class Steen extends JApplet implements Runnable { private int xwaarde, ywaarde, width, heigth; private boolean raised,vallen; private Thread steenDraad = null; public void start() { if(steenDraad == null) {steenDraad = new Thread(this, "Steen"); steenDraad.start();} xwaarde = 60; //mag onverandered blijven ywaarde = 0; //variabel --> vallen width = 40; heigth = 20; raised = true; } public void run() { vallen = true; repaint(); while(vallen) { try { Thread.sleep(50); } catch(InterruptedException ex) { } if(ywaarde == 300) ywaarde = 0; ywaarde += 25; repaint(); } } public void paint(Graphics g) { g.setColor(Color.blue); g.fillRect(xwaarde,ywaarde, width, heigth); g.clearRect(xwaarde,ywaarde - 25, width, heigth); } public void stop() { vallen = false; } }