title: Gui getter and setter method
body: <p>I'm a beginner java student currently working a gui assignment that involves calculating purchases made at a auto motive garage, I have the majority complete but I'm stuck when making a summary panel class.The first block of code is my handler class without issues and the next is the summary both include the needed imported packages, I can't seem to figure out how to pass on the variable values from the handler to the summary page and assign them to the textFields. I apologize in for the format of this post it is in fact my first. If needed I can provide the code from my other panels</p>
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  import java.text.DecimalFormat;
  import javax.swing.JOptionPane;
  
  /**
   * Contains the event handling code to run the calculation and exit button functions
  
  public class JoesAutoHandler implements ActionListener
  {
  // instance variables of the JoesAutoGUI and Tax rate
  private final double TAX_RATE = 0.07;
  protected JoesAutoGUI gui;    
  
  /**
   * Constructor for objects of class EventHandler
   */
  public JoesAutoHandler(JoesAutoGUI gui)
  {
      // initialize instance of gui referencing the JoesAutoGUI
      this.gui = gui;
  }
  
  /**
   * method called when the buttons are clicked
   * performs the required total calculations when the calcButton is clicked
   * closes program when exit button is clicked
   *       
   */
  public void actionPerformed(ActionEvent e)
  {
      //variables used within this method
          double subTotal,
                 totalTax = 0,
                 routineCharge = 0,
                 nonRoutineCharge = 0,
                 totalCharges = 0;
          int    totalCustomers = 0,
                 response;
      
      //sets the values decimal formats           
      DecimalFormat dollar = new DecimalFormat(&quot;$#,##0.00&quot;);
          
      // method runs when the calcButton is clicked
      if(e.getSource() == gui.calcButton)
      {  
          //call method to retrieve the routine charge amount
          routineCharge = gui.routinePanel.getCharges();
          
          //call the getCharges() method to retrieve the non routine charge amount
          nonRoutineCharge = gui.nonRoutinePanel.getCharges();
          
          //calculations for subtotal           
          subTotal = routineCharge + nonRoutineCharge;
          
          //calculates the total tax
          totalTax = subTotal * TAX_RATE;
          
          //calculates the total charges
          totalCharges = subTotal + totalTax;
          
          //Displays the variable values after the calculations in the details window in dollar format            
          response = JOptionPane.showConfirmDialog(null, &quot;Total Routine Service Charge:&quot; + dollar.format(routineCharge) + &quot;\n&quot; 
                                            + &quot;Non Routine Service Charge:&quot; + dollar.format(nonRoutineCharge) + &quot;\n&quot;
                                            + &quot;Sub-Total:&quot; + dollar.format(subTotal) + &quot;\n&quot; 
                                            + &quot;Total tax:&quot; + dollar.format(totalTax) + &quot;\n&quot; 
                                            + &quot;Total Charges:&quot; + dollar.format(totalCharges),
                                            &quot;Comfirm Customer Reciept&quot;,
                                            JOptionPane.OK_CANCEL_OPTION,
                                            JOptionPane.INFORMATION_MESSAGE);
                                            
          //increase the totalCustomer value when the calcButton is clicked
          totalCustomers++;
          
      }
      //if the exitButton is clicked the program will close
      if(e.getSource() == gui.exitButton) System.exit(0);
  }
  }
  
  import java.awt.*;
  import javax.swing.*;
  import java.text.DecimalFormat;
  
  public class SummaryPanel extends JPanel
  {
  // instance variables for the labels, text fields and values
  protected JLabel totalCustomersLabel,
                   totalRoutineChargesLabel,
                   totalNonRoutineChargesLabel,
                   totalTaxLabel,
                   totalChargesLabel;
  protected JoesAutoHandler gui;                 
  protected JTextField totalCustomersTextField,
                       totalRoutineChargesTextField,
                       totalNonRoutineChargesTextField,
                       totalTaxTextField,
                       totalChargesTextField;                      
  //instance of the summary panel variables
  private int totalCustomers;    
  private double totalRoutineServiceCharges;    
  private double totalNonRoutineServiceCharges;    
  private double totalTax;    
  private double totalCharges;
  
  /**
   * Constructor for objects of class SummaryPanel
   */
  public SummaryPanel()
  {      
      
     // creates decimal format objects fot the totals variables
     DecimalFormat totalCustomerDf = new DecimalFormat(&quot;#,##0.00&quot;);
     DecimalFormat totalRoutineChargesDf = new DecimalFormat(&quot;#,##0.00&quot;);
     DecimalFormat totalNonRoutineChargesDf = new DecimalFormat(&quot;#,##0.00&quot;);
     DecimalFormat totalTaxDf = new DecimalFormat(&quot;#,##0.00&quot;);
     DecimalFormat totalChargesDf = new DecimalFormat(&quot;#,##0.00&quot;);
     
     //creates the gridLayout with 5 row and 2 columns
     setLayout(new GridLayout(5,2));
     
     //creates the label objects and sets the string text
     totalCustomersLabel = new JLabel(&quot;Total Customers:&quot;);       
     totalRoutineChargesLabel = new JLabel(&quot;Total Routine Charges:&quot;);
     totalNonRoutineChargesLabel = new JLabel(&quot;Total NonRoutine Charges:&quot;);
     totalTaxLabel = new JLabel(&quot;Total Tax:&quot;);       
     totalChargesLabel = new JLabel(&quot;Total Charges:&quot;);
  
     //creates the text field components and initalizes them to 0
     totalCustomersTextField = new JTextField(&quot;0&quot;);
     totalRoutineChargesTextField = new JTextField(&quot;0&quot;);
     totalNonRoutineChargesTextField = new JTextField(&quot;0&quot;);
     totalTaxTextField = new JTextField(&quot;0&quot;);
     totalChargesTextField = new JTextField(&quot;0&quot;);
           
     totalCustomersTextField.setText(&quot;&quot; + totalCustomers);
  
     //sets the labels to right-justification
     totalCustomersLabel.setHorizontalAlignment(JLabel.RIGHT);
     totalRoutineChargesLabel.setHorizontalAlignment(JLabel.RIGHT);
     totalNonRoutineChargesLabel.setHorizontalAlignment(JLabel.RIGHT);
     totalTaxLabel.setHorizontalAlignment(JLabel.RIGHT);
     totalChargesLabel.setHorizontalAlignment(JLabel.RIGHT);
     
     //sets the textboxes to right-justification
     totalCustomersTextField.setHorizontalAlignment(JTextField.RIGHT);
     totalRoutineChargesTextField.setHorizontalAlignment(JTextField.RIGHT);
     totalNonRoutineChargesTextField.setHorizontalAlignment(JTextField.RIGHT);
     totalTaxTextField.setHorizontalAlignment(JTextField.RIGHT);
     totalChargesTextField.setHorizontalAlignment(JTextField.RIGHT);
     
     //makes the textboxes read only
     totalCustomersTextField.setEditable(false);
     totalRoutineChargesTextField.setEditable(false);
     totalNonRoutineChargesTextField.setEditable(false);
     totalTaxTextField.setEditable(false);
     totalChargesTextField.setEditable(false);             
     
     //adds components to the panel
      add(totalCustomersLabel);
      add(totalCustomersTextField);
      add(totalRoutineChargesLabel);
      add(totalRoutineChargesTextField);
      add(totalNonRoutineChargesLabel);
      add(totalNonRoutineChargesTextField);                
      add(totalTaxLabel);
      add(totalTaxTextField);       
      add(totalChargesLabel);     
      add(totalChargesTextField);
      
      //converts the variable data types to String 
      String totalCustomersText = Integer.toString(totalCustomers);
      String totalRoutineServiceChargesText = Double.toString(totalRoutineServiceCharges);
      String totalNonRoutineServiceChargesText = Double.toString(totalNonRoutineServiceCharges);
      String totalTaxText = Double.toString(totalTax);
      String totalChargesText = Double.toString(totalCharges);
      
      //sets the component text fields with the variable values
      totalCustomersTextField.setText(totalCustomersText);
      totalRoutineChargesTextField.setText(totalRoutineServiceChargesText);
      totalNonRoutineChargesTextField.setText(totalNonRoutineServiceChargesText);
      totalTaxTextField.setText(totalTaxText);
      totalChargesTextField.setText(totalChargesText);
  }
  
  /**
   *get set methods for all variables
   */
  public int getTotalCustomers()
  {
      // returns total customers
      return totalCustomers;
  }
  
  public void setTotalCustomers(int totalCustomers)
  {
      //set total customers
      this.totalCustomers = totalCustomers;
  }
  
  public double getTotalRoutineServiceChargess()
  {
      // gets totalRoutineServiceCharges
      return totalRoutineServiceCharges;
  }
  
  public void setTotalRoutineServiceCharges(double totalRoutineServiceCharges)
  {
      //sets totalRoutineServiceCharges
      this.totalRoutineServiceCharges = totalRoutineServiceCharges;
  }
  
  public double getTotalNonRoutineCharges()
  {
      //gets totalNonRoutineServiceCharges
      return totalNonRoutineServiceCharges;
  }
  
  public void setTotalNonRoutineServiceCharges(double totalNonRoutineServiceCharges)
  {
      //sets totalNonRoutineServiceCharges
      this.totalNonRoutineServiceCharges = totalNonRoutineServiceCharges;
  }
  
  public double getTotalTax()
  {
      // gets total Tax
      return totalTax;
  }
  
  public void setTotalTax(double totalTax)
  {
      //set total tax
      this.totalTax = totalTax;
  }
  
  public double getTotalCharges()
  {
      // gets total charges
      return totalCharges;
  }
  
  public void setTotalCharges(double totalCharges)
  {
      //sets total charges 
      this.totalCharges = totalCharges;
  }
  }
  </code></pre>