wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes what affects addActionListener(this)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what affects addActionListener(this)?" Watch "what affects addActionListener(this)?" New topic
Author

what affects addActionListener(this)?

richard gallagher
Greenhorn

Joined: Mar 15, 2008
Posts: 9
Hello,

Ive added a custom button to a frame, within the main class "GameManager"
as follows.



The code (now with //)
calls the error "The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (GameManager)". Im not too sure what i need to change or add to fix this. Anyone know why (in general) this error appears?

Thankyou
rg
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

Hi!

addActionListener() takes an argument of type ActionListener! So your main class which you pass to addActionListener() via "this" has to implement the interface ActionListener! Is this the case?

Marco
richard gallagher
Greenhorn

Joined: Mar 15, 2008
Posts: 9
Hi,

Thanks for reply. Yup that was the fix, eclipse give me the option to do that which was good. Im just origonally thought that you wouldnt manually do some coding to initiate it

Thanks

rg
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

But it would be a really cool feature if your IDE would know which interfaces to implement before you do
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what affects addActionListener(this)?