This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes addActionListener problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "addActionListener problem" Watch "addActionListener problem" New topic
Author

addActionListener problem

Jesse Crockett
Ranch Hand

Joined: Feb 03, 2005
Posts: 129
what's the problem with this code? I get errors that the buttons aren't found inside the actionPerformed method...

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Declare the buttons as private class members, not as local variables in the constructor.


[My Blog]
All roads lead to JavaRanch
Jesse Crockett
Ranch Hand

Joined: Feb 03, 2005
Posts: 129
thanks! :-)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: addActionListener problem
 
Similar Threads
Java grid colouring in game
Button Listener
ActionListener -- where to put anonymous inner class?
[newbie] Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
ActionListener and Event