Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

addActionListener Error  RSS feed

 
George Avilez
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me why there is an error at line 26? The error is: method addActionListener in class AbstractButtom

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The addActionListener(ActionListener listener) expects an action listener type. In your code, this is GUIsampler i.e. a JFrame instance.
In other words you say have a beer but you actually pass a glass of milk. No wonder the compiler is complaining. I would too if you gave me milk instead of beer

 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the section from the Swing tutorial on How to Write an ActionListener for an example that shows you how to implement the ActionListener interface.
 
George Avilez
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool Thanks! btw any of you guys have any links to examples on how to create a submenu within a submenu?
 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I gave you a link to the tutorial.

Did you look at the Table of Contents?
 
George Avilez
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh sry I didn't realize there was more to it. Thank you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!