title: return value from Action Listener
body: <p>I've got this function, I want to return a value when I click on the button. I know it doesn't work, but how do I fix this? I already googled about it, but couldn't find something relevant.</p>
  
  <p>My code:</p>
  
  <pre><code>public String OutputText()
  {
      layout.show(mainpanel, "PANEL");
      testbutton.addActionListener(new ActionListener() 
      {
          public void actionPerformed(ActionEvent arg0) 
          {
              return textfield.getText();
          }
      });
  }
  </code></pre>