import java.awt.*;
import java.awt.event.*;
class game0527 extends Canvas {
Frame fr;
int x;
public void paint( Graphics g ) {
g.fillRect(50*x, 50,50,50);
}
game0527() {
x=0;
fr =
new Frame( "フレーム" );
setSize( 500, 500 );
fr.add( this, BorderLayout.NORTH );
Button bu = new Button( "
ボタン" );
fr.add( bu, BorderLayout.CENTER );
bu.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
x=x+1;
repaint();
}
} );
fr.pack();
fr.setVisible( true );
fr.addWindowListener(new stopwin());
}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}
public static void main( String[] args ) {
game0527 test= new game0527();
}
}
最終更新:2011年02月25日 07:03