动作器 java
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/*in main*/
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println('x');
}
});
java swing按钮点击
JButton b = new JButton("push me");
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//your actions
}
});