button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
.... }
});
这算是创建一个匿名类,实现一个ActionListener接口吗?可是这这种写法看起来怪怪的:)
{
public void actionPerformed(ActionEvent e) {
.... }
});
这算是创建一个匿名类,实现一个ActionListener接口吗?可是这这种写法看起来怪怪的:)
pubilc void actionPerformed(ActionEvent e){
...}
}button.addActionListener(new BL());
........}A a = new A;
button.addActionListener(a);
用匿名类有时候可以简化代码