Oscar F
Oscar F

Reputation: 323

Class is not Abstract?

private class HandlerClass implements ActionListener
    {
        public void actionPerfomed(ActionEvent event)
        {
            JOptionPane.showMessageDialog(null, String.format("%s", event.getActionCommand));
        }
    }

This is part of my code and when I compile, I get an error saying HandlerClass is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener. To my understanding, actionPerformed should override HandlerClass shouldn't it? I already tried adding "abstract" before the word class but then I get another error since I can't call an abstract class. I'm not sure if maybe there's an exception I can use to solve this?

Upvotes: 0

Views: 108

Answers (1)

MadProgrammer
MadProgrammer

Reputation: 347184

Basically, you have a spelling mistake...

actionPerfomed

Should be

actionPerformed
           ^---- ;)

You may also want to use the @Override annotation which will tell you when you're attempting to override a method that doesn't exist in the parent classes...

@Override
public void actionPerformed(ActionEvent event)
{
    JOptionPane.showMessageDialog(null, String.format("%s", event.getActionCommand));
}

Upvotes: 7

Related Questions