File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass variables to actionPerformed method

 
S. Hoysala
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic