public void run(){
while(temp){
repaint();
try {
Thread.sleep(50);
} catch (InterruptedException e){
e.printStackTrace();
}
}
}
public void paint(Graphics g){
Dimension d =getSize();
int x =(int)(Math.random()*d.width);
int y =(int)(Math.random()*d.height);
Color c = g.getColor();
g.setColor(Color.red);
g.fillOval(x, y,10, 10);
g.setColor(c);
}
public static void main(String args[]){
TestAwt ta = new TestAwt();
Thread thread = new Thread(ta);
thread.run();