This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes How to pass variables to actionPerformed method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "How to pass variables to actionPerformed method" Watch "How to pass variables to actionPerformed method" New topic
Author

How to pass variables to actionPerformed method

S. Hoysala
Greenhorn

Joined: Dec 29, 2011
Posts: 3
int b = 0;
someButton.addActionListener(this);

I want a way to somehow pass b to the actionPerformed method whenever someButton is clicked. How can I do that?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

For a method local variable to be accessible in an inner class, it must be declared final. Since the instance of the anonymous inner class may continue to exist after the method has exited, it makes its copy of the variable. So the value of the variable must not change.


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass variables to actionPerformed method
 
Similar Threads
Redirecting Output
overriding inner class methods?
Swing
how do i generate an ActionEvent ?
Boolean problem