I have to create a Pizza GUI that shows pizza size choices and topping choices for pepperoni and mushrooms and then calculate the total. I'm having trouble constructing the GUI. Down in the createCenterPanel method Eclipse is tell me that radioButtonPanel, checkBoxPanel, and pricePanel cannot be resolved to a type.
import java.awt.*;
import javax.swing.*;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
public class PizzaPriceFrame extends JFrame {
private JPanel pizzaPanel;
private static final int FRAME_WIDTH = 300;
private static final int FRAME_HEIGHT = 300;
JRadioButton smallButton = new JRadioButton("Small");
JRadioButton mediumButton = new JRadioButton("Medium");
JRadioButton largeButton = new JRadioButton("Large");
JCheckBox pepperoniButton = new JCheckBox("Pepperoni");
JCheckBox mushroomsButton = new JCheckBox("Mushrooms");
JTextField priceTextField = new JTextField();
public PizzaPriceFrame() {
setSize(FRAME_WIDTH, FRAME_HEIGHT);
pizzaPanel = new JPanel();
add(pizzaPanel, BorderLayout.CENTER);
createRadioButtonPanel();
createCheckBoxPanel();
createCenterPanel();
createPricePanel();
}
public void createRadioButtonPanel() {
JPanel radioButtonPanel = new JPanel();
radioButtonPanel.setLayout(new GridLayout(3, 1));
radioButtonPanel.setBorder(new TitledBorder(new EtchedBorder(), "Size"));
radioButtonPanel.add(smallButton);
radioButtonPanel.add(mediumButton);
radioButtonPanel.add(largeButton);
}
public void createCheckBoxPanel() {
JPanel checkBoxPanel = new JPanel();
checkBoxPanel.setLayout(new GridLayout(2, 1));
checkBoxPanel.add(pepperoniButton);
checkBoxPanel.add(mushroomsButton);
}
public void createPricePanel() {
JPanel pricePanel = new JPanel(); // Uses FlowLayout
pricePanel.add(new JLabel("Your Price:"));
pricePanel.add(priceTextField);
}
public void createCenterPanel() {
JPanel centerPanel = new JPanel(); // Uses FlowLayout
centerPanel.add(radioButtonPanel);
centerPanel.add(checkBoxPanel);
// Frame uses BorderLayout by default
add(centerPanel, BorderLayout.CENTER);
add(pricePanel, BorderLayout.SOUTH);
}
}
Any help is GREATLY appreciated.