title: I'm recieving Error: <identifier expected> and Error: illegal start of type for JComboBoxes from addItem statements
body: <p>I have a project for my Java class that requires me to add to JComboBoxes and set events for when they are clicked on to change a pizza price as needed.  Also I know there is something not correct with the event code.  It needs to handle both combo boxes and something isn't correct.  I'm having a tough time understanding what I need to change. Here is the code:</p>
  
  <pre><code>// File name JPizza.java
  // Written by Me
  // Written on 4-26-2014
  
  import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  
  public class JPizza extends JFrame implements ActionListener
  {
      final int EXTRALARGE_PRICE = 14;
      final int LARGE_PRICE = 11;
      final int MEDIUM_PRICE = 9;
      final int SMALL_PRICE = 7;
  
      final int CHEESE_PRICE = 0;
      final int PEPPERONI_PRICE = 1;
      final int SAUSAGE_PRICE = 1;
      final int REDONION_PRICE = 1;
      final int GREENPEPPER_PRICE = 1;
      final int MUSHROOM_PRICE = 1;
  
      int totalPrice = EXTRALARGE_PRICE + CHEESE_PRICE;
  
      JLabel applicationLabel = new JLabel("Pizza Price Calculator");
  
      JLabel optionExplainLabel = new JLabel("Select what size, and what topping you want from the drop down menus. Prices are listed in the combo boxes.");
  
      JLabel pizzaSize = new JLabel("Pizza size");
      JComboBox pizzaSizeValue = new JComboBox();
          pizzaSizeValue.addItem("Extra Large - $14");
          pizzaSizeValue.addItem("Large - $11");
          pizzaSizeValue.addItem("Medium - $9");
          pizzaSizeValue.addItem("Small - $7");
          pizzaSizeValue.setSelectedItem("Extra Large - $14");
  
      JLabel pizzaTopping = new JLabel ("Pizza topping");
      JComboBox pizzaToppingValue = new JComboBox();
          pizzaToppingValue.addItem("Cheese - free");
          pizzaToppingValue.addItem("Pepperoni - $1");
          pizzaToppingValue.addItem("Sausage - $1");
          pizzaToppingValue.addItem("Red Onion - $1");
          pizzaToppingValue.addItem("Green Pepper - $1");
          pizzaToppingValue.addItem("Mushroom - $1");
          pizzaToppingValue.setSelectedItem("Cheese - free");
  
      JLabel priceLabel = new JLabel("The price for your pizza is");
      JTextField totPrice = new JTextField(3);
  
  
      public JPizza()
      {
          super("Pizza Price Calculator");
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setLayout(new FlowLayout());
          add(applicationLabel);
          add(optionExplainLabel);
          add(pizzaSize);
          add(pizzaSizeValue);
          add(pizzaTopping);
          add(pizzaToppingValue);
          add(priceLabel);
          add(totPrice);
          totPrice.setText("$" + totalPrice);
          pizzaSizeValue.addActionListener(this);
          pizzaToppingValue.addActionListener(this);
      }
  
      public void actionPerformed(ActionEvent event)
      {
          int pizzaSizeCost = 14;
          int pizzaToppingCost = 0;
          JComboBox comboBox = (JComboBox) event.getSource();
          Object source = event.getSource();
          Object select = comboBox.getSelectedItem();
          if(source == pizzaSizeValue)
          {
              if(select.equals("Extra Large - $14"))
                  pizzaSizeCost = EXTRALARGE_PRICE;
              if(select.equals("Large - $11"))
                  pizzaSizeCost = LARGE_PRICE;
              if(select.equals("Medium - $9"))
                  pizzaSizeCost = MEDIUM_PRICE;
              if(select.equals("Small - $7"))
                  pizzaSizeCost = SMALL_PRICE;
          }
          if(source == pizzaToppingValue)
          {
              if(select.equals("Cheese - free"))
                  pizzaSizeCost = CHEESE_PRICE;
              if(select.equals("Pepperoni $1"))
                  pizzaSizeCost = PEPPERONI_PRICE;
              if(select.equals("Sausage $1"))
                  pizzaSizeCost = SAUSAGE_PRICE;
              if(select.equals("Red Onion $1"))
                  pizzaSizeCost = REDONION_PRICE;
              if(select.equals("Green Pepper $1"))
                  pizzaSizeCost = GREENPEPPER_PRICE;
              if(select.equals("Mushroom $1"))
                  pizzaSizeCost = MUSHROOM_PRICE;
          }       
      }
  
      public static void main(String[] args)
      {
          JPizza aFrame =
              new JPizza();
              final int WIDTH = 300;
              final int HEIGHT = 200;
              aFrame.setSize(WIDTH, HEIGHT);
              aFrame.setVisible(true);
      }
  }
  </code></pre>
  
  <p>Here are the errors:</p>
  
  <pre><code>c:\Java\Homework\CH14\YouDoIt&gt;javac JPizza.java
  JPizza.java:31: error: &lt;identifier&gt; expected
                  pizzaSizeValue.addItem("Extra Large - $14");
                                        ^
  JPizza.java:31: error: illegal start of type
                  pizzaSizeValue.addItem("Extra Large - $14");
                                         ^
  JPizza.java:32: error: &lt;identifier&gt; expected
                  pizzaSizeValue.addItem("Large - $11");
                                        ^
  JPizza.java:32: error: illegal start of type
                  pizzaSizeValue.addItem("Large - $11");
                                         ^
  JPizza.java:33: error: &lt;identifier&gt; expected
                  pizzaSizeValue.addItem("Medium - $9");
                                        ^
  JPizza.java:33: error: illegal start of type
                  pizzaSizeValue.addItem("Medium - $9");
                                         ^
  JPizza.java:34: error: &lt;identifier&gt; expected
                  pizzaSizeValue.addItem("Small - $7");
                                        ^
  JPizza.java:34: error: illegal start of type
                  pizzaSizeValue.addItem("Small - $7");
                                         ^
  JPizza.java:35: error: &lt;identifier&gt; expected
                  pizzaSizeValue.setSelectedItem("Extra Large - $14");
                                                ^
  JPizza.java:35: error: illegal start of type
                  pizzaSizeValue.setSelectedItem("Extra Large - $14");
                                                 ^
  JPizza.java:39: error: &lt;identifier&gt; expected
                  pizzaToppingValue.addItem("Cheese - free");
                                           ^
  JPizza.java:39: error: illegal start of type
                  pizzaToppingValue.addItem("Cheese - free");
                                            ^
  JPizza.java:40: error: &lt;identifier&gt; expected
                  pizzaToppingValue.addItem("Pepperoni - $1");
                                           ^
  JPizza.java:40: error: illegal start of type
                  pizzaToppingValue.addItem("Pepperoni - $1");
                                            ^
  JPizza.java:41: error: &lt;identifier&gt; expected
                  pizzaToppingValue.addItem("Sausage - $1");
                                           ^
  JPizza.java:41: error: illegal start of type
                  pizzaToppingValue.addItem("Sausage - $1");
                                            ^
  JPizza.java:42: error: &lt;identifier&gt; expected
                  pizzaToppingValue.addItem("Red Onion - $1");
                                           ^
  JPizza.java:42: error: illegal start of type
                  pizzaToppingValue.addItem("Red Onion - $1");
                                            ^
  JPizza.java:43: error: &lt;identifier&gt; expected
                  pizzaToppingValue.addItem("Green Pepper - $1");
                                           ^
  JPizza.java:43: error: illegal start of type
                  pizzaToppingValue.addItem("Green Pepper - $1");
                                            ^
  JPizza.java:44: error: &lt;identifier&gt; expected
                  pizzaToppingValue.addItem("Mushroom - $1");
                                           ^
  JPizza.java:44: error: illegal start of type
                  pizzaToppingValue.addItem("Mushroom - $1");
                                            ^
  JPizza.java:45: error: &lt;identifier&gt; expected
                  pizzaToppingValue.setSelectedItem("Cheese - free");
                                                   ^
  JPizza.java:45: error: illegal start of type
                  pizzaToppingValue.setSelectedItem("Cheese - free");
                                                    ^
  24 errors
  
  Any help would be appreciated!
  </code></pre>