• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why won't my action listener work?  RSS feed

 
David Middleton
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am making this code
i
and I keep getting an error at the action performed part it says that Multiple markers at this line
- void is an invalid type for the variable actionPerformed
- Syntax error on token ")", ; expected
- Syntax error on token "(", ; expected
 
Ron McLeod
Bartender
Posts: 1603
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch 

The error you are seeing is because you are declaring your actionPerformed method inside the constructor.  Since your class it implementing ActionListener, you do need a actionPerformed method, but don't place inside the constructor or in another method.  Actually you already do have an actionPerformed method, so just just get rid of the method inside the constructor.

Also, since your class is also implementing ItemLister, you are going to need to add an itemStateChanged as well.

Finally, with the code as-is, your actionListener is not going to get called - you will need to wire it in to a Swing component first.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!