{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

PizzaOrderPanel - PizzaOrderPanel.java Authors Lewis and...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // PizzaOrderPanel.java Authors: Lewis and Loftus // // Solution to Programming Project 9.11 // //******************************************************************** import java.util.*; import java.awt.event.*; import java.awt.*; import javax.swing.*; import javax.swing.border.*; import java.text.NumberFormat; public class PizzaOrderPanel extends JPanel { ArrayList pizzaOrder; ButtonGroup sizeGroup; ButtonGroup crustGroup; ButtonGroup sauceGroup; JCheckBox[] cheeseCheckBoxes; JCheckBox[] meatToppingCheckBoxes; JCheckBox[] veggieToppingCheckBoxes; JLabel numPizzasLabel; JLabel totalPriceLabel; float previousPrice; PizzaOrderPortal portal; //----------------------------------------------------------------- // Set up the pizza ordering GUI //----------------------------------------------------------------- public PizzaOrderPanel(PizzaOrderPortal orderPortal) { portal = orderPortal; previousPrice = 0.0f; pizzaOrder = new ArrayList(); setLayout(new BorderLayout()); add(createSizePanel(), BorderLayout.NORTH); add(createPizzaPanel(),BorderLayout.CENTER); add(createOrderButtonPanel(), BorderLayout.SOUTH); } //----------------------------------------------------------------- // Creates the pizza size panel //----------------------------------------------------------------- JPanel createSizePanel() { sizeGroup = new ButtonGroup(); JPanel sizePanel = new JPanel(); sizePanel.setBorder(new EtchedBorder()); sizePanel.add(new JLabel("Size: ")); // add sizes from class Pizza JRadioButton rButton; for (int i = 0; i < Pizza.SIZES.length; i++) { rButton = new JRadioButton(Pizza.SIZES[i]); rButton.setActionCommand(String.valueOf(i));
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
sizeGroup.add(rButton); sizePanel.add(rButton); if (i==0) rButton.setSelected(true); } return sizePanel; } //----------------------------------------------------------------- // Creates the upper panel in the main pizza panel //----------------------------------------------------------------- JPanel createUpperPanel() { JPanel upperPanel = new JPanel(); JPanel container = new JPanel(); container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS)); // set up crust choices crustGroup = new ButtonGroup(); JPanel crustPanel = new JPanel(); crustPanel.setLayout(new BoxLayout(crustPanel, BoxLayout.Y_AXIS)); crustPanel.setBorder(new TitledBorder(new EtchedBorder(), "Crust")); // add crust types from class Pizza JRadioButton rButton; for (int i = 0; i < Pizza.CRUST_TYPES.length; i++) { rButton = new JRadioButton(Pizza.CRUST_TYPES[i]); rButton.setActionCommand(String.valueOf(i)); crustGroup.add(rButton); crustPanel.add(rButton); if (i==0) rButton.setSelected(true); } container.add(crustPanel); // set up sauce choices
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern