rendered paste bodyimport java.applet.*;
import java.awt.*;
import java.util.Random;
public class False extends Applet implements Runnable {
int width, height;
int i = 0;
Thread t = null;
boolean threadSuspended;
int x1 = retRandNum();
int y1 = retRandNum();
public void init() {
width = getSize().width;
height = getSize().height;
setBackground(Color.black);
}
public void destroy() { }
public void start() {
if (t == null) {
t = new Thread(this);
threadSuspended = false;
t.start();
} else {
if (threadSuspended) {
threadSuspended = false;
synchronized(this) {
notify();
}
}
}
}
public void stop() {
threadSuspended = true;
}
public void run() {
try {
while (true) {
i++;
if (i == 10) {
i = 0;
}
if (threadSuspended) {
synchronized(this) {
while (threadSuspended) {
wait();
}
}
}
repaint();
t.sleep(10);
}
}
catch (InterruptedException e) { }
}
public void paint(Graphics g) {
g.setColor(Color.blue);
g.fillOval(width-x1, height-y1, 10, 10);
if(x1 == width) {
x1++;
y1++;
} else {
x1--;
y1--;
}
}
public int retRandNum() {
Random newRand = new Random();
return newRand.nextInt(300);
}
}