你能否解释一下这种方法传递给addActionListener方法的方法是什么?我知道JButton创建了一个类型的按钮变量并定义了事件监听器.我不太清楚这个addActionListener论点,即其中的actionPerformed方法定义.我可以在哪里准备这种方法?谢谢.
JButton button = new JButton("New button");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.out.println("Hello");
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
461 次 |
| 最近记录: |