title: How can I add to the quantity variable every time the user clicked the button?
body: <p>I have two <code>JFrame</code> in my GUI.</p>
  
  <p>One is <code>order</code> frame and another is <code>payment</code> frame.</p>
  
  <p>I would like to add onto the <code>quantity</code> variable every time when the user clicked on the <code>button</code>. I have added the increment-logic under the button method, but it seems only applicable in that method only. It won't add <code>+1</code> into my array variable.</p>
  
  <p>Here is my code for this:</p>
  
  <pre><code>class Bun extends javax.swing.JFrame {
   String decimal = "0.00";
   DecimalFormat df = new DecimalFormat(decimal);
   public final String [] bname = new String [] {"Tuna Sandwich","Garlic Bread","Redbean Bun"};
   public final double [] bprice = new double [] {1.20, 1.50, 1.50};
   public double [] bsub = new double [9];
   public int [] bquantity = new int[]{0,0,0};
   public double bsubtotal;
  
  private void BtnTunaSandwichActionPerformed(java.awt.event.ActionEvent evt) {                                                
      bquantity[0]++;
      numTunaSandwich.setText(Integer.toString(bquantity[0]));
  }                                               
  
  private void BtnGarlicBreadActionPerformed(java.awt.event.ActionEvent evt) {                                               
     bquantity[1]++;
     numGarlicBread.setText(Integer.toString(bquantity[1]));
  }                                              
  
  private void BtnRedbeanBunActionPerformed(java.awt.event.ActionEvent evt) {                                              
     bquantity[2]++;
     numRedbeanBun.setText(Integer.toString(bquantity[2]));
  }                      
  
  public void calculatesub()
  {
      for(int counter=0;counter&lt;bsub.length;counter++)
      {
          bsub[counter]=bquantity[counter]*bprice[counter];
      }
  }
  public void setsubtotal()
  {
      for(int counter=0;counter&lt;bsub.length;counter++)
      {
          bsubtotal += bsub[counter];
      }
  }
  public String getsubtotal()
  {
      return (df.format(bsubtotal));
  }
  </code></pre>
  
  <p>This is my Payment frame code:</p>
  
  <pre><code>private void subtotalActionPerformed(java.awt.event.ActionEvent evt) {                                         
          Bun bun = new Bun();
          bun.calculatesub();
          bun.setsubtotal();
          subtotal.setText(bun.getsubtotal());
  }      
  </code></pre>
  
  <p>Whenever I run the program and try to calculate the subtotal, it shows <code>0</code>.</p>
  
  <p>My interface:</p>
  
  <p><a href="https://i.stack.imgur.com/mpuZ4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mpuZ4.png" alt="Order Frame"></a>
  <a href="https://i.stack.imgur.com/6MUae.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6MUae.png" alt="Payment Frame"></a></p>