JFrame myframe = new JFrame("My Sample Frame");
JButton mybutton = new JButton("Okay");
谁能给我解释一下这部分。
mybutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
//Assuming that the content here will do something.
}
最佳答案
您到底对代码有什么不了解的地方?
代码向按钮添加了一个 Action 监听器。单击按钮时将调用 Action 监听器的 actionPerformed
方法。
请注意 anonymous inner class在这里使用。
关于java - JFrame Action 监听器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6344269/