日期:2014-05-20  浏览次数:20591 次

新手求指教,关于ActiontionListener

------解决方案--------------------
this是指代码被执行时的本类当前对象(ButtonDemo)
------解决方案--------------------
this是指代码被执行时的本类当前对象(ButtonDemo)
------解决方案--------------------
建议在用addActionListener()方法时用内名内部类的方法实现actionPerformed()方法
jbtStart.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
thread.start();
jbtStart.setEnabled(false);
}
});

------解决方案--------------------
哦明白你意思了 参数类型ActionListener是一个接口类型,但是实参this的类ButtonDemo也是实现了ActionListener这个接口的,因此它就是这种接口类型 
------解决方案--------------------
The method ActionListener(ActionListener)in the type AbstractButton is not applicable for the arguements(ButtonDemo)不明白说的是什么意思 

根据你的报错,我怀疑ButtonDemo类实现的ActionListener接口不是java.awt.event.ActionListener,而是一个自定义的重名类

根据两点推测
ActionPerformed方法实现了接口中方法
ButtonDemo有黄色警告