import java.awt.*;
import java.awt.event.*;
class MyButton extends Button {
MyButton(String s) {
super(s);
enableEvents(AWTEvent.ACTION_EVENT_MASK);
}
protected void processActionEvent(ActionEvent e) {
System.out.println("按钮" + e.getActionCommand() + "按下!");
}
}
public class TestEvent {
public static void main(String[] args) {
Frame f = new Frame("TestEvent");
MyButton b = new MyButton("login");
b.setSize(100, 100);
f.add(b);
f.setBackground(Color.LIGHT_GRAY);
f.setVisible(true);
f.pack();
}
}