title: JCheckBox not updating when selected
body: <p>I'm using JCheckBox to find what a costumer wants to buy, if the JCheckBox(hat) is selected then total += hatprice, but it's not updating the total.
  My code :</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  
  public class NgaFillimi extends JFrame implements ActionListener{
  
      private JCheckBox hat;
      private JLabel thetotal;
      private int total = 0;
  
      public NgaFillimi() {
  
          Container c = getContentPane();
          c.setLayout(new FlowLayout());
          hat = new JCheckBox("hat");
          thetotal = new JLabel("The total is " + total);
  
          hat.addActionListener(this);
  
          c.add(thetotal);
          c.add(hat);
      }
  
      @Override
      public void actionPerformed(ActionEvent evt) {
          if (hat.isSelected()) {
              total += 50;
          }
      }
  
      public static void main(String[] args) {
          NgaFillimi gui = new NgaFillimi();
          gui.setSize(300,200);
          gui.setVisible(true);
          gui.setDefaultCloseOperation(EXIT_ON_CLOSE);
          gui.setTitle("GUI");
      }
  
  }
  </code></pre>