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
Register / Login
JavaRanch » Java Forums » Java » Applets
Reply 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: 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.
 
IntelliJ Java IDE
 
subject: How to pass variables to actionPerformed method
 
Threads others viewed
Swing
overriding inner class methods?
how do i generate an ActionEvent ?
Boolean problem
Redirecting Output
developer file tools