import java.awt.*;
import java.awt.Graphics;
import java.awt.event.*;
class pro0405 extends Frame implements Runnable{
Frame f;
Thread th;
int num;
public static void main(String[] args){
Frame f=new pro0405();
f.setTitle("
pro0405");
f.setSize(500,500);
f.setBackground(Color.yellow);
f.show();
}
pro0405() {
addWindowListener(
new stopwin());
num=1;
th=new Thread(this);
th.start();
}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}
public void paint( Graphics g ) {
g.setColor(Color.yellow);
g.fillRect(
100,100,300,300);
g.setColor(Color.red);
g.fillRect(10*num+100,100+10*num,10,10);
num=num+1;
}
public void update(Graphics g) {
paint(g);
}
public void run() {
int n;
for (n=1;n<
101;n++){
repaint();
try{th.sleep(100);} catch(InterruptedException e) { }
}
}
}
最終更新:2010年09月18日 17:33