In: Computer Science
******You do not need to get everything working exactly as it says, I mostly just need an outline of how to create this GUI and add up the costs and print them all out. Any help at all will be greatly appreciated*******
Design and implement a Java program that creates a GUI that will allow a customer to order pizza and other items from a Pizza Paarlor. The customer should be able to order a variety of items which are listed below. The GUI should allow the customer (via JavaFX UI Controls - text areas, buttons, checkbox, radio button, etc.) to input the following information:
Pricing (assign these prices to each item)
Base Price for items :
Additional fees for Toppings:
Conditions:
// UI CODE
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class MyPanel extends JPanel {
private JLabel Pizza Parlor;
private JLabel FirstName;
private JTextField jcomp3;
private JLabel LastName;
private JTextField jcomp5;
private JLabel Phone;
private JTextField jcomp7;
private JLabel jcomp8;
private JTextField jcomp9;
private JLabel jcomp10;
private JLabel jcomp11;
private JTextField jcomp12;
private JComboBox Types;
private JLabel Pizza Toppings;
private JComboBox jcomp15;
private JButton Total Sum;
private JButton jcomp17;
public MyPanel() {
//construct preComponents
String[] TypesItems = {"Small", "Large", "calzone", "garlic knots"};
String[] jcomp15Items = {"Plain", "Extra cheese", "Mushrooms", "Pepperoni"};
//construct components
Pizza Parlor = new JLabel ("Pizza Parlor");
FirstName = new JLabel ("First Name");
jcomp3 = new JTextField (5);
LastName = new JLabel ("Last Name");
jcomp5 = new JTextField (5);
Phone = new JLabel ("Phone No.");
jcomp7 = new JTextField (5);
jcomp8 = new JLabel ("Address");
jcomp9 = new JTextField (5);
jcomp10 = new JLabel ("Type of Pizza");
jcomp11 = new JLabel ("Quantity");
jcomp12 = new JTextField (5);
Types = new JComboBox (TypesItems);
Pizza Toppings = new JLabel ("Pizza Toppings");
jcomp15 = new JComboBox (jcomp15Items);
Total Sum = new JButton ("Total Sum");
jcomp17 = new JButton ("Submit Info");
//set components properties
Pizza Parlor.setToolTipText ("Pizza Parlor");
Types.setToolTipText ("Types of Pizza");
//adjust size and set layout
setPreferredSize (new Dimension (667, 393));
setLayout (null);
//add components
add (Pizza Parlor);
add (FirstName);
add (jcomp3);
add (LastName);
add (jcomp5);
add (Phone);
add (jcomp7);
add (jcomp8);
add (jcomp9);
add (jcomp10);
add (jcomp11);
add (jcomp12);
add (Types);
add (Pizza Toppings);
add (jcomp15);
add (Total Sum);
add (jcomp17);
//set component bounds (only needed by Absolute Positioning)
Pizza Parlor.setBounds (265, 10, 70, 25);
FirstName.setBounds (5, 70, 100, 25);
jcomp3.setBounds (80, 75, 100, 20);
LastName.setBounds (5, 120, 100, 25);
jcomp5.setBounds (80, 120, 100, 20);
Phone.setBounds (5, 160, 100, 25);
jcomp7.setBounds (80, 160, 100, 20);
jcomp8.setBounds (5, 200, 70, 25);
jcomp9.setBounds (80, 205, 105, 60);
jcomp10.setBounds (290, 70, 100, 25);
jcomp11.setBounds (295, 110, 100, 25);
jcomp12.setBounds (410, 115, 100, 25);
Types.setBounds (410, 75, 100, 25);
Pizza Toppings.setBounds (295, 155, 100, 25);
jcomp15.setBounds (410, 155, 100, 25);
Total Sum.setBounds (360, 220, 100, 25);
jcomp17.setBounds (45, 315, 100, 25);
}
public static void main (String[] args) {
JFrame frame = new JFrame ("MyPanel");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add (new MyPanel());
frame.pack();
frame.setVisible (true);
}
}