Need some help with ActionListener error
Hey there, I'm a bit newb when it comes to this so I'll ask you guys.
Every time I'm busy with my home course Java, I get the same ActionListener error. I really don't understand what it means.
Here is the error:
Code:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
The type EtiketPaneel must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)
at H024.EtiketPaneel.actionPerformed(EtiketPaneel.java:6)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
And here is the coding where the error occurs:
Code:
package H024;
import javax.swing.*;
import java.awt.event.*;
public class EtiketPaneel extends JPanel implements ActionListener
{
private JTextField LabelAmount;
private JTextField PaperAmount;
private JButton CalculateButton;
private JTextArea ResultField;
public EtiketPaneel()
{
CalculateButton = new JButton("Calculate");
CalculateButton.addActionListener(this);
LabelAmount = new JTextField("", 8);
PaperAmount = new JTextField("", 8);
ResultField = new JTextArea(6, 25);
add(new JLabel("How many labels would you like to print?"));
add(LabelAmount);
add(new JLabel("How many labels per paper?"));
add(PaperAmount);
add(CalculateButton);
add(ResultField);
}
public void ShowResult(int LabelAmount, int PaperAmount)
{
int PaperNeeded = ((LabelAmount - 1) / PaperAmount + 1);
int Remaining = PaperNeeded * PaperAmount - LabelAmount;
String Result = "Amount of paper needed: " + PaperNeeded + "\n" + "Unprinted labels: " + Remaining;
ResultField.setText(Result);
}
public void actionPreformed(ActionEvent e)
{
int Label = Integer.parseInt(LabelAmount.getText());
int Paper = Integer.parseInt(PaperAmount.getText());
ShowResult(Label, Paper);
}
}
I hope you guys can help me on this.
Thanks in advance, DaBananaboat.