Reputation: 37
Why isn't this ActionListener
working? I've tried to follow tutorials but I keep getting the same error.
public class listenerTest implements ActionListener {
@Override //<-- This adds another error
public void actionPerformed(ActionEvent e)
{
System.out.println("Message"+e.toString());
System.exit(0);
}
}
And in the other file:
loginButton.addActionListener(new listenerTest());
NetBeans says
there are compilation errors on listenerTest class "listenerTest is not abstract and
does not override abstract method actionPerformed(ActionEvent) in ActionListener"`
and the error on @Override
says method does not override or implement a method from supertype
.
Any help how to fix this?
Upvotes: 0
Views: 65
Reputation: 151
Add this two lines top of your class :
import java.awt.event.ActionEvent; import java.awt.event.ActionListener;
Upvotes: 1