title: Return a value for use in different class
body: <p>I have the class BossInfo which extends JPanel and has a few components like JLabel, JTextField. My main method is in another file ("DamageCalculator").
  Basically, a value is entered into a JTextField via an action listener and I'd like to pass that value to a different file (to use it in calculations). I'm having a lot of trouble with the logic. Here is my class:</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  
  public class BossInfo extends JPanel {
  
      private JLabel      bossLabel, resultLabel;
      private JTextField  bossHp;
      String bossHpText = new String("");
      int valRecd = 0;
  
      public BossInfo() {
          //Labels
          bossLabel = new JLabel("Boss HP: (Hit Enter to set)");
          resultLabel = new JLabel("---");
          //Text field for user input of boss hp
          bossHp = new JTextField(15);
          bossHp.addActionListener(new TempListener());
  
          //add components
          add(bossLabel);
          add(bossHp);
          add(resultLabel);
  
      } //end BossInfo object 
  
      public void setVal(int valRecd) {
          this.valRecd = valRecd;
      }
  
      private class TempListener implements ActionListener {
          public void actionPerformed(ActionEvent event) {            
              int hp;
              bossHpText = bossHp.getText();
              hp = Integer.valueOf(bossHpText);
              dc.setVal(hp);
              resultLabel.setText(bossHpText);
          }//end action performed
      }//end TempListener
  } //end class BossInfo
  </code></pre>
  
  <p>How can I use bossHpText in another class? The "actionPerformed" gets mad if it's any return type other than void so I'm not sure it's meant to return anything.</p>
  
  <p>EDIT: Code updated based on suggestions.</p>