| 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: 3214
|
|
|
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.
|
 |
 |
|
|
subject: How to pass variables to actionPerformed method
|
|
|