title: isSelected() does not recognize JRadioButton and JCheckBox are selected
body: <p>I'm new here, and this is my very first post.</p>
  
  <p>I have a very specific need to code this very trivial application only invoking the isSelected() method to check whether or not a JRadioButton or JCheckBox have been selected. This means I do not want to loop through a ButtonGroup and invoke its getSelection() method.</p>
  
  <p>My code is also identical to the one from a textbook authored by Tony Gaddis, which I am currently learning from: <em>Starting Out With Java</em>, <em>From Control Structures through Objects</em>. <em>4th Edition</em>. </p>
  
  <p>This is a <strong>logical problem</strong>, as the application compiles and runs without error.</p>
  
  <p>Here's what's going on: </p>
  
  <p>I have four classes: BagelsPanel, CoffeePanel, ToppingsPanel and the GUI class, BagelApp - all of which extend JPanel <strong>except</strong> the BagelApp class which extends a JFrame. </p>
  
  <p>The purpose of the app is to let a user make coffee, bagel and toppings selections and return the total price of all their selections. The problem is it keeps returning $0.00. </p>
  
  <p>My suspicion is, for some reason, isSelected() isn't recognizing something is selected.</p>
  
  <p>I will post the BagelsPanel and the GUI class code that involves these problems below:  </p>
  
  <pre><code>public double calcBagel() {
  
      double total = 0.00;
  
      if(button1.isSelected())
          total = PLAIN;
      else if(button2.isSelected()) 
          total = WHOLE_WHEAT;
      else if(button3.isSelected()) 
          total = CINNA_RAISON;
      else if(button4.isSelected()) 
          total = EVERYTHING;
  
      return total;
  }
  </code></pre>
  
  <p>The above is the calcBagel() method in the BagelsPanel class that's invoking the isSelected() method to check which JRadioButton is selected, then <strong>assigning</strong> its price to total. Below is the GUI class:</p>
  
  <pre><code>public void buildPanel() {
  
      panel = new JPanel();
      calc = new JButton("Calculate");
      calc.addActionListener(new ButtonListener());
      panel.add(calc);
  }
  private class ButtonListener implements ActionListener {
  
      public void actionPerformed(ActionEvent e) {
  
          double subtotal = 0.0;
          double total = 0.0;
          bagels = new BagelPanel();
          coffee = new CoffeePanel();
          toppings = new ToppingsPanel();
  
          subtotal = bagels.calcBagel() + coffee.calcCoffee() +
                      toppings.calcToppings();
          double tax = subtotal * TAX;
          total = subtotal + tax;
  
          DecimalFormat dollar = new DecimalFormat("$0.00");
  
          JOptionPane.showMessageDialog(null, "Your total is: " 
                      + dollar.format(total));    
      }
  }
  </code></pre>
  
  <p>Here's some insight: if I change the double variable total, in the calcBagel() method inside the BagelsPanel class to 1.0, and then run the application and click on the JRadioButton "Calculate," it accurately props up a JOptionPane telling me my total is $1.06 (the final double variable TAX is set at 0.06).</p>
  
  <p>I'd really appreciate any help I can get. I'm still a beginner in Java and don't quite understand why my logic is incorrect. I'm embarrassed this might be extremely trivial but I've checked the book and the code is identical. Any suggestions?</p>