import java.awt.*;
import java.awt.event.*;
class game0901 extends Frame implements Runnable{
int x,y;
public static void main(String [] args) {
Frame f=new game0901();
f.setTitle("game0901");
f.setSize(700,700);
f.setBackground(Color.yellow);
f.setVisible(true);
}
game0901(){
Thread th=new Thread(this);
th.start();
addWindowListener(new stopwin());
}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}
public void run(){
int t;
x=300;
y=500;
t=0;
while(t<30){
y=y-10;
repaint();
try{
Thread.sleep(100);
}catch(InterruptedException e){}
t=t+1;
}
repaint();
}
public void paint(Graphics g){
g.setColor(Color.black);
g.fillRect(100,100,500,500);
g.setColor(Color.red);
g.fillRect(x,y,10,10);
}
}
最終更新:2011年02月12日 08:32