[英]having problems with ActionListener java
Getting an Error when i try to add a second Action Listener. 我尝试添加第二个动作侦听器时出错。 I have two different JButtons set up and have one of them working ok but when i try add a Action Listener for the second one i get the following error:
我有两个不同的JButtons设置,其中一个工作正常,但当我尝试为第二个添加一个动作监听器时,我收到以下错误:
is not abstract and does not override abstract method actionPerformed(ActionEvent) in ActionListener
next.addActionListener(new ActionListener (){
and this is the code of the two Action Listeners. 这是两个动作监听器的代码。
next.addActionListener(new ActionListener (){
public void preformedAction(ActionEvent e){
}
});
close.addActionListener(new ActionListener (){
public void actionPerformed(ActionEvent event){
frame.dispose(); //Closes Window
}//End ActionPreformed
});//End Of Close Action
the two buttons are "next" and "close" 两个按钮是“下一个”和“关闭”
The method you need to override is actionPerformed(ActionEvent)
, not preformedAciton(ActionEvent)
. 您需要覆盖的方法是
actionPerformed(ActionEvent)
,而不是preformedAciton(ActionEvent)
。 The ActionListener
you are creating and adding to next
uses the latter method signature, which is incorrect, and thus the error. 您正在创建并添加到
next
的ActionListener
使用后一种方法签名,这是不正确的,因此也就是错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.