添加按钮监听器的正确方法是什么?( )
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEventevt) { }
});jButton1.addActionListener(ActionListener() {
public void actionPerformed(new ActionEventevt) { }
});jButton1.addActionListener(new ActionListener() {
public void actionPerformed(new ActionEventevt) { }
});jButton1.addActionListener(ActionListener() {
public void actionPerformed(ActionEventevt) { }
});1、actionPerformed函数声明里面的参数,不应该用new。
2、addActionListener函数的调用可以使用匿名类的方式简化代码。
2、addActionListener函数的调用可以使用匿名类的方式简化代码。