Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what affects addActionListener(this)?

 
richard gallagher
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But it would be a really cool feature if your IDE would know which interfaces to implement before you do
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic