アットウィキロゴ

どん01 02

import java.awt.*;
import java.awt.Graphics;
import java.awt.event.*;

class pro extends Frame implements Runnable{

Frame f;
Thread th;
int bx,by,dx,dy;

public static void main(String[] args){
Frame f=new pro();
f.setSize(700,700);
f.setBackground(Color.yellow);
f.show();
}

pro() {
addWindowListener(new stopwin());
bx=1;
by=1;
dx=1;
dy=0;
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(0,0,700,700);
g.setColor(Color.red);
g.fillRect(100+50*bx,600-50*by,10,10);
}

public void update(Graphics g) {
paint(g);
}

public void run() {
int i;
for (i=1;i<100;i++){
repaint();
bx=bx+dx;
if (bx>10)bx=10;
if (bx<0)bx=0;
try{th.sleep(200);} catch(InterruptedException e) { }
}
}


}
最終更新:2010年10月04日 10:26