import java.awt.*;
import java.awt.event.*;
class pro0302 extends Frame {
public static void main(String[] args) {
pro0302 frame = new pro0302("pro0302");
}
public pro0302(String str) {
super(str);
setSize(200, 200);
setLayout([[new]] FlowLayout());
Button button = new Button("click!");
button.addActionListener(new MyListener());
add(button);
setVisible(true);
}
/*
/* ActionEventを受け取るリスナ
/* [[ボタン]]がクリックされるとコンソールに表示する
/*/
class MyListener implements ActionListener {
// イベントが発生すると、actionPerformed()メソッドが呼ばれる
public void actionPerformed(ActionEvent e) {
System.out.println(e.getActionCommand());
}
}
}
最終更新:2010年09月19日 01:00