import java.awt.*;
import java.awt.event.*;
class pro0303 extends Frame {
public static void main(String[] args) {
pro0303 frame = new pro0303("pro0303");
}
public pro0303(String str) {
super(str);
setSize(200, 200);
setLayout([[new]] FlowLayout());
Button button = new Button("click!");
button.addActionListener(new MyListener());
add(button);
setVisible(true);
addWindowListener(new stopwin());
}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}
class MyListener implements ActionListener {
// イベントが発生すると、actionPerformed()メソッドが呼ばれる
public void actionPerformed(ActionEvent e) {
System.out.println(e.getActionCommand());
}
}
}
最終更新:2010年09月19日 01:10