public class Broadway extends Applet implements Runnable
{ Thread animation; int locx, locy; // location of rectangle int width, height; // dimensions of rectangle static final byte UP = 0; // direction of motion static final byte DOWN = 1; static final byte LEFT = 2; static final byte RIGHT = 3; byte state; // state the rect is in // length of pausing interval static final int REFRESH_RATE = 100; // in ms // applet methods: public void init() { System.out.println(">> init <<"); setBackground(Color.black); locx = 80; // parameters of center rect locy = 100; width = 110; height = 90; state = UP; }
public void start() {
System.out.println(">> start <<"); animation = new Thread(this); if (animation != null) { animation.start(); } }