title: Netbeans: Update textfield on button event
body: <p>I am attempting to make a basic character creation planner in netbeans as an attempt to learn Java so forgive me if my question is a bit silly.</p>
  
  <p>I have created the a text field that needs to be updated with a formula each time the relevant stat is changed.</p>
  
  <p>In this example the luck and charisma stat affects the barter skill. So when I change either of these stats I need the formula to run again to update the barter skill.</p>
  
  <p>Currently the formula runs on creation of the object but not on update of another stat.</p>
  
  <p>Here is my current (relevant) code:</p>
  
  <pre><code>package AppPackage;
  
  import javax.swing.JOptionPane;
  
  
  public class StartGUI extends javax.swing.JFrame {
  
  
      public StartGUI() {
          initComponents();
      }
  
  
      @SuppressWarnings("unchecked")
      // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt;                          
      private void initComponents() {
  
          BarterPts = new javax.swing.JTextField();
          Chr = new javax.swing.JTextField();
          ChrPlus = new javax.swing.JButton();
          Luck = new javax.swing.JTextField();
  
  
          BarterPts.setEditable(false);
          BarterPts.setText("0");
          BarterPts.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  BarterPtsActionPerformed(evt);
              }
          });
          getContentPane().add(BarterPts, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 110, 30, -1));
          int a = Integer.parseInt(Chr.getText()),l = Integer.parseInt(Luck.getText()),barter;
          barter = (2 + (a*2) + (l/2) );
          BarterPts.setText(String.valueOf(barter));
  
  
      //plus button to add to the Charisma stat.
      private void ChrPlusActionPerformed(java.awt.event.ActionEvent evt) {                                        
          int a = Integer.parseInt(Chr.getText()),i,l = Integer.parseInt(SLeft.getText());
          if (a == 10) {
              //print error
              JOptionPane.showMessageDialog(null, "The Charisma value cannot exceed 10.", "Error", JOptionPane.ERROR_MESSAGE);
          }
          else if (l == 0) {
              JOptionPane.showMessageDialog(null, "You have no special points remaining.", "Error", JOptionPane.ERROR_MESSAGE);
          }
          else{
              l=--l;
              SLeft.setText(String.valueOf(l));
              i=++a;
              Chr.setText(String.valueOf(i));
      }                                       
      }
  
      private void BarterPtsActionPerformed(java.awt.event.ActionEvent evt) {                                          
  
      }       
  </code></pre>
  
  <p>There are variable declarations below but I have not included them.</p>