• Post Reply Bookmark Topic Watch Topic
  • New Topic

ActionListener Problem  RSS feed

 
Rena Tjioe
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Morning to all,

I am rather new to Java programming and I have a problem when I compile the program.
I have an error that read : addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (Elements), and I have no idea what that means.

The error was pointed to: aluminium.addActionListener(this); in line 9.

I have tried importing java.awt.event as well but it does not seem to be the problem.



Can you can tell me where I went wrong?

Much appriciated.
Many thanks in advance

Rena Tjioe
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

The error message means that the Elements class doesn't match the argument type(s) expected by the addActionListener method. This method expects a single argument, an instance of a class that implements the ActionListener interface. Although Elements provides an "actionPerformed(ActionEvent)" method, I'm guessing it doesn't actually declare "class Elements implements ActionListener" -- but it needs to.
 
Rena Tjioe
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh I see. I know where I have made the error.

Thank you
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!