读书人

生手求指教关于ActiontionListener

发布时间: 2013-03-19 17:22:05 作者: rapoo

新手求指教,关于ActiontionListener
生手求指教,关于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有黄色警告

读书人网 >J2SE开发

热点推荐