アットウィキロゴ

java0602

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

class game0602 extends Frame {
int x;

public static void main(String[] args) {
game0602 frame = new game0602();
}
  
game0602() {
x=1;
setSize(500, 500);
setLayout(new FlowLayout());
Button button = new Button("click!");
button.addActionListener(new baction());
add(button);
setVisible(true);
               addWindowListener(new stopwin());
}

class stopwin extends WindowAdapter{
   public void windowClosing(WindowEvent we){System.exit(0);}
   }

class baction implements ActionListener {
public void actionPerformed(ActionEvent e) {
x=x+1;
repaint();
}
}

public void paint( Graphics g ) {
g.fillRect(50*x, 50,50,50);
}

}
最終更新:2011年02月25日 07:19