title: Pass arguments into JButton ActionListener
body: <p>I'm looking for a way to pass a variable or string or anything into an anonymous actionlistener ( or explicit actionlistener ) for a JButton. Here is what I have:</p>
  
  <pre><code>public class Tool {
  ...
    public static void addDialog() {
      JButton addButton = new JButton( "Add" );
      JTextField entry = new JTextField( "Entry Text", 20 );
      ...
      addButton.addActionListener( new ActionListener( ) {
        public void actionPerformed( ActionEvent e )
        {
          System.out.println( entry.getText() );
        }
      });
    ...
    }
  }
  </code></pre>
  
  <p>Right now I just declare <code>entry</code> to be a global variable, but I hate that way of making this work. Is there a better alternative?</p>