File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 4664
    
    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