hi there i am trying to creat a subtotal for each row i have created and for each item in the combo box i dont know how to do this can some help plz
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package orderingsystem;
import javax.swing.*;
import java.lang.String;
import java.awt.*;
import java.awt.event.*;
import java.text.NumberFormat;
import java.util.Locale;
/**
*
* @author
*/
public class OrderingSystem extends JFrame {
//widgets
//Genral widegets
JPanel panelWidget;
Toolkit toolkit;
JButton buttonWidget;
//Jlabels
JLabel PizzaShackWidget;
JLabel priceLabel;
JLabel priceLabel2;
JLabel priceLabel3;
JLabel priceLabel4;
JLabel priceLabel5;
JLabel priceLabel6;
JLabel priceLabel7;
JLabel priceLabel8;
JLabel priceLabel9;
JLabel priceLabel10;
JLabel priceLabel11;
JLabel priceLabel12;
JLabel priceLabel13;
JLabel priceLabel14;
JLabel priceLabel15;
JLabel priceLabel16;
JLabel priceLabel17;
JLabel priceLabel18;
JLabel priceLabel19;
JLabel priceLabel20;
JLabel priceLabel2l;
JLabel priceLabel22;
JLabel priceLabel23;
JLabel priceLabel24;
JLabel priceLabel25;
JLabel priceLabel26;
JLabel priceLabel27;
JLabel priceLabel28;
JLabel priceLabel29;
JLabel priceLabel30;
JLabel priceLabel31;
JLabel priceLabel32;
JLabel priceLabel33;
JLabel priceLabel34;
JLabel priceLabel35;
JLabel priceLabel36;
JLabel priceLabel37;
JLabel priceLabel38;
JLabel priceLabe139;
JLabel priceLabel40;
JLabel subtotalLabel;
JLabel subtotalLabel2;
JLabel CommentsLabel;
JLabel totalLabel;
JLabel numberLabel1;
JLabel numberLabel2;
JLabel numberLabel3;
JLabel numberLabel4;
JLabel numberLabel5;
JLabel numberLabel6;
JLabel numberLabel7;
JLabel numberLabel8;
JLabel numberLabel9;
JLabel numberLabel10;
//JCombox
JComboBox DrinksComboBoxWidget;
JComboBox DrinksCombo1;
JComboBox PizzaCombo1;
JComboBox PizzaBaseCombo1;
JComboBox IceCombo1;
JComboBox DrinksCombo2;
JComboBox PizzaCombo2;
JComboBox PizzaBaseCombo2;
JComboBox IceCombo2;
JComboBox DrinksCombo3;
JComboBox PizzaCombo3;
JComboBox PizzaBaseCombo3;
JComboBox IceCombo3;
JComboBox DrinksCombo4;
JComboBox PizzaCombo4;
JComboBox PizzaBaseCombo4;
JComboBox IceCombo4;
JComboBox DrinksCombo5;
JComboBox PizzaCombo5;
JComboBox PizzaBaseCombo5;
JComboBox IceCombo5;
JComboBox DrinksCombo6;
JComboBox PizzaCombo6;
JComboBox PizzaBaseCombo6;
JComboBox IceCombo6;
JComboBox DrinksCombo7;
JComboBox PizzaCombo7;
JComboBox PizzaBaseCombo7;
JComboBox IceCombo7;
JComboBox DrinksCombo8;
JComboBox PizzaCombo8;
JComboBox PizzaBaseCombo8;
JComboBox IceCombo8;
JComboBox DrinksCombo9;
JComboBox PizzaCombo9;
JComboBox PizzaBaseCombo9;
JComboBox IceCombo9;
JComboBox DrinksCombo10;
JComboBox PizzaCombo10;
JComboBox PizzaBaseCombo10;
JComboBox IceCombo10;
//JTextField
JTextField NameWidget;
JTextField NumbweOfPeopleWidget;
JTextField TimeSeatedWidget;
JTextField quantityTextField;
JTextField CommentsField1;
JTextField CommentsField2;
JTextField CommentsField3;
JTextField CommentsField4;
JTextField CommentsField5;
JTextField CommentsField6;
JTextField CommentsField7;
JTextField CommentsField8;
JTextField CommentsField9;
JTextField CommentsField10;
//Close of Widgets
/**
*
*/
public OrderingSystem() {
setSize(1000, 600);
setTitle("Graphical User Interface");
setDefaultCloseOperation(EXIT_ON_CLOSE);
toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width / 2 - getWidth() / 2, size.height / 2 - getHeight() / 2);
JPanel panel = new JPanel();
getContentPane().add(panel);
panel.setLayout(null);
CommentsLabel = new JLabel();
CommentsLabel.setBounds (735 , 35 , 100 ,25);
CommentsLabel.setText("Comments");
priceLabel = new JLabel();
priceLabel.setBounds(220, 10, 100, 25);
priceLabel.setText("0.00");
quantityTextField = new JTextField();
quantityTextField.setBounds(330, 10, 100, 35);
quantityTextField.setText("0.00");
quantityTextField.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
}
public void focusLost(FocusEvent event) {
recalculate();
}
});
subtotalLabel = new JLabel();
subtotalLabel.setBounds(440, 10, 100, 35);
subtotalLabel.setText("0.00");
subtotalLabel2 = new JLabel();
subtotalLabel2.setBounds(700, 60, 100, 35);
subtotalLabel2.setText("0.00");
totalLabel = new JLabel();
totalLabel.setBounds(440, 500, 100, 35);
totalLabel.setText("0.00");
//Pizza Shack Label
PizzaShackWidget = new JLabel();
PizzaShackWidget.setBounds(10, 10, 200, 20);
PizzaShackWidget.setText("Pizza Shack");
//Table Selector
String[] TableStrings = {"Please Select Table Number", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25"};
//table number
JComboBox TableList = new JComboBox(TableStrings);
TableList.setBounds(200, 10, 200, 20);
TableList.setSelectedIndex(0);
TableList.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
}
});
//Order 1
numberLabel1 = new JLabel();
numberLabel1.setBounds(10, 65, 200, 20);
numberLabel1.setText("Order 1");
//Pizza Combo box
String[] Pizza = {"Please select a Pizza", "Cheese and tomato", "Ham and Pineapple", "Vegetarian", "Meat Feast", "Seafood"};
PizzaCombo1 = new JComboBox(Pizza);
PizzaCombo1.setBounds(75, 60, 150, 30);
PizzaCombo1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo1.getSelectedItem().equals("Cheese and tomato")) {
priceLabel.setText("3.50");
} else if (PizzaCombo1.getSelectedItem().equals("Ham and Pineapple")) {
priceLabel.setText("4.20");
} else if (PizzaCombo1.getSelectedItem().equals("Vegetarian")) {
priceLabel.setText("5.20");
} else if (PizzaCombo1.getSelectedItem().equals("Meat Feast")) {
priceLabel.setText("5.80");
} else if (PizzaCombo1.getSelectedItem().equals("Seafood")) {
priceLabel.setText("5.60");
}
recalculate();
}
});
//Base Combo
String[] Base = {"Please select a Pizza Base", "Thin & Crispy", "Traditional", "Stuffed Crust", "Deep Pan", "Cheesey Bites"};
JComboBox PizzaBaseCombo1 = new JComboBox(Base);
PizzaBaseCombo1.setBounds(235, 60, 195, 30);
PizzaBaseCombo1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo1.getSelectedItem().equals("Thin & Crispy")) {
priceLabel2.setText("0.0");
} else if (PizzaCombo1.getSelectedItem().equals("Traditional")) {
priceLabel2.setText("0.0");
} else if (PizzaCombo1.getSelectedItem().equals("Stuffed Crust")) {
priceLabel2.setText("0.0");
} else if (PizzaCombo1.getSelectedItem().equals("Deep Pan")) {
priceLabel2.setText("0.0");
} else if (PizzaCombo1.getSelectedItem().equals("Cheesey Bites")) {
priceLabel2.setText("0.0");
}
recalculate();
}
});
//Drinks Combo Box
String[] drinks = {"Please select a drink", "Cola", "Lemonade", "Fanta"};
DrinksCombo1 = new JComboBox(drinks);
DrinksCombo1.setBounds(445, 60, 150, 30);
DrinksCombo1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (DrinksCombo1.getSelectedItem().equals("Cola")) {
priceLabel3.setText("0.90");
} else if (DrinksCombo1.getSelectedItem().equals("Lemonade")) {
priceLabel3.setText("0.95");
} else if (DrinksCombo1.getSelectedItem().equals("Fanta")) {
priceLabel3.setText("0.95");
}
recalculate();
}
});
//Ice or not
String[] ice = {"Ice", "With Ice", "Without Ice"};
IceCombo1 = new JComboBox(ice);
IceCombo1.setBounds(600, 60, 80, 30);
IceCombo1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (IceCombo1.getSelectedItem().equals("With Ice")) {
priceLabel4.setText("0.0");
} else if (IceCombo1.getSelectedItem().equals("WithoutIce")) {
priceLabel4.setText("0.0");
}
recalculate();
}
});
//Comments box
CommentsField1 = new JTextField();
CommentsField1.setBounds(690, 60, 170, 30);
//Order 2
numberLabel2 = new JLabel();
numberLabel2.setBounds(10, 105, 200, 20);
numberLabel2.setText("Order 2");
//Pizza Combo box
String[] Pizza2 = {"Please select a Pizza", "Cheese and tomato", "Ham and Pineapple", "Vegetarian", "Meat Feast", "Seafood"};
PizzaCombo2 = new JComboBox(Pizza2);
PizzaCombo2.setBounds(75, 100, 150, 30);
PizzaCombo2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo2.getSelectedItem().equals("Cheese and tomato")) {
priceLabel5.setText("3.50");
} else if (PizzaCombo1.getSelectedItem().equals("Ham and Pineapple")) {
priceLabel5.setText("4.20");
} else if (PizzaCombo2.getSelectedItem().equals("Vegetarian")) {
priceLabel5.setText("5.20");
} else if (PizzaCombo2.getSelectedItem().equals("Meat Feast")) {
priceLabel5.setText("5.80");
} else if (PizzaCombo2.getSelectedItem().equals("Seafood")) {
priceLabel5.setText("5.60");
}
recalculate();
}
});
//Base Combo
String[] Base2 = {"Please select a Pizza Base", "Thin & Crispy", "Traditional", "Stuffed Crust", "Deep Pan", "Cheesey Bites"};
JComboBox PizzaBaseCombo2 = new JComboBox(Base2);
PizzaBaseCombo2.setBounds(235, 100, 195, 30);
PizzaBaseCombo2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo2.getSelectedItem().equals("Thin & Crispy")) {
priceLabel6.setText("0.0");
} else if (PizzaCombo2.getSelectedItem().equals("Traditional")) {
priceLabel6.setText("0.0");
} else if (PizzaCombo2.getSelectedItem().equals("Stuffed Crust")) {
priceLabel6.setText("0.0");
} else if (PizzaCombo2.getSelectedItem().equals("Deep Pan")) {
priceLabel6.setText("0.0");
} else if (PizzaCombo2.getSelectedItem().equals("Cheesey Bites")) {
priceLabel6.setText("0.0");
}
recalculate();
}
});
//Drinks Combo Box
String[] drinks2 = {"Please select a drink", "Cola", "Lemonade", "Fanta"};
DrinksCombo2 = new JComboBox(drinks2);
DrinksCombo2.setBounds(445, 100, 150, 30);
DrinksCombo2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (DrinksCombo2.getSelectedItem().equals("Cola")) {
priceLabel7.setText("0.90");
} else if (DrinksCombo2.getSelectedItem().equals("Lemonade")) {
priceLabel7.setText("0.95");
} else if (DrinksCombo2.getSelectedItem().equals("Fanta")) {
priceLabel7.setText("0.95");
}
recalculate();
}
});
//Ice or not
String[] ice2 = {"Ice", "With Ice", "Without Ice"};
IceCombo2 = new JComboBox(ice2);
IceCombo2.setBounds(600, 100, 80, 30);
IceCombo2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (IceCombo2.getSelectedItem().equals("With Ice")) {
priceLabel8.setText("0.0");
} else if (IceCombo2.getSelectedItem().equals("WithoutIce")) {
priceLabel8.setText("0.0");
}
recalculate();
}
});
//comments field
CommentsField2 = new JTextField();
CommentsField2.setBounds(690, 100, 170, 30);
//Order 3
numberLabel3 = new JLabel();
numberLabel3.setBounds(10, 145, 200, 20);
numberLabel3.setText("Order 3");
//Pizza Combo box
String[] Pizza3 = {"Please select a Pizza", "Cheese and tomato", "Ham and Pineapple", "Vegetarian", "Meat Feast", "Seafood"};
PizzaCombo3 = new JComboBox(Pizza3);
PizzaCombo3.setBounds(75, 140, 150, 30);
PizzaCombo3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo3.getSelectedItem().equals("Cheese and tomato")) {
priceLabel9.setText("3.50");
} else if (PizzaCombo3.getSelectedItem().equals("Ham and Pineapple")) {
priceLabel9.setText("4.20");
} else if (PizzaCombo3.getSelectedItem().equals("Vegetarian")) {
priceLabel9.setText("5.20");
} else if (PizzaCombo3.getSelectedItem().equals("Meat Feast")) {
priceLabel9.setText("5.80");
} else if (PizzaCombo3.getSelectedItem().equals("Seafood")) {
priceLabel9.setText("5.60");
}
recalculate();
}
});
//Base Combo
String[] Base3 = {"Please select a Pizza Base", "Thin & Crispy", "Traditional", "Stuffed Crust", "Deep Pan", "Cheesey Bites"};
JComboBox PizzaBaseCombo3 = new JComboBox(Base3);
PizzaBaseCombo3.setBounds(235, 140, 195, 30);
PizzaBaseCombo3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo3.getSelectedItem().equals("Thin & Crispy")) {
priceLabel10.setText("0.0");
} else if (PizzaCombo3.getSelectedItem().equals("Traditional")) {
priceLabel10.setText("0.0");
} else if (PizzaCombo3.getSelectedItem().equals("Stuffed Crust")) {
priceLabel10.setText("0.0");
} else if (PizzaCombo3.getSelectedItem().equals("Deep Pan")) {
priceLabel10.setText("0.0");
} else if (PizzaCombo3.getSelectedItem().equals("Cheesey Bites")) {
priceLabel10.setText("0.0");
}
recalculate();
}
});
//Drinks Combo Box
String[] drinks3 = {"Please select a drink", "Cola", "Lemonade", "Fanta"};
DrinksCombo3 = new JComboBox(drinks3);
DrinksCombo3.setBounds(445, 140, 150, 30);
DrinksCombo3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (DrinksCombo3.getSelectedItem().equals("Cola")) {
priceLabel11.setText("0.90");
} else if (DrinksCombo3.getSelectedItem().equals("Lemonade")) {
priceLabel11.setText("0.95");
} else if (DrinksCombo3.getSelectedItem().equals("Fanta")) {
priceLabel11.setText("0.95");
}
recalculate();
}
});
//Ice or not
String[] ice3 = {"Ice", "With Ice", "Without Ice"};
IceCombo3 = new JComboBox(ice2);
IceCombo3.setBounds(600, 140, 80, 30);
IceCombo3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (IceCombo3.getSelectedItem().equals("With Ice")) {
priceLabel12.setText("0.0");
} else if (IceCombo3.getSelectedItem().equals("WithoutIce")) {
priceLabel12.setText("0.0");
}
recalculate();
}
});
//comments field
CommentsField3 = new JTextField();
CommentsField3.setBounds(690, 140, 170, 30);
//Order 4
numberLabel4 = new JLabel();
numberLabel4.setBounds(10, 185, 200, 20);
numberLabel4.setText("Order 4");
//Pizza Combo box
String[] Pizza4 = {"Please select a Pizza", "Cheese and tomato", "Ham and Pineapple", "Vegetarian", "Meat Feast", "Seafood"};
PizzaCombo4 = new JComboBox(Pizza4);
PizzaCombo4.setBounds(75, 180, 150, 30);
PizzaCombo4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo4.getSelectedItem().equals("Cheese and tomato")) {
priceLabel13.setText("3.50");
} else if (PizzaCombo4.getSelectedItem().equals("Ham and Pineapple")) {
priceLabel13.setText("4.20");
} else if (PizzaCombo4.getSelectedItem().equals("Vegetarian")) {
priceLabel13.setText("5.20");
} else if (PizzaCombo4.getSelectedItem().equals("Meat Feast")) {
priceLabel13.setText("5.80");
} else if (PizzaCombo4.getSelectedItem().equals("Seafood")) {
priceLabel13.setText("5.60");
}
recalculate();
}
});
//Base Combo
String[] Base4 = {"Please select a Pizza Base", "Thin & Crispy", "Traditional", "Stuffed Crust", "Deep Pan", "Cheesey Bites"};
JComboBox PizzaBaseCombo4 = new JComboBox(Base4);
PizzaBaseCombo4.setBounds(235, 180, 195, 30);
PizzaBaseCombo4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo4.getSelectedItem().equals("Thin & Crispy")) {
priceLabel14.setText("0.0");
} else if (PizzaCombo4.getSelectedItem().equals("Traditional")) {
priceLabel14.setText("0.0");
} else if (PizzaCombo4.getSelectedItem().equals("Stuffed Crust")) {
priceLabel14.setText("0.0");
} else if (PizzaCombo4.getSelectedItem().equals("Deep Pan")) {
priceLabel14.setText("0.0");
} else if (PizzaCombo4.getSelectedItem().equals("Cheesey Bites")) {
priceLabel14.setText("0.0");
}
recalculate();
}
});
//Drinks Combo Box
String[] drinks4 = {"Please select a drink", "Cola", "Lemonade", "Fanta"};
DrinksCombo4 = new JComboBox(drinks4);
DrinksCombo4.setBounds(445, 180, 150, 30);
DrinksCombo4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (DrinksCombo4.getSelectedItem().equals("Cola")) {
priceLabel15.setText("0.90");
} else if (DrinksCombo4.getSelectedItem().equals("Lemonade")) {
priceLabel15.setText("0.95");
} else if (DrinksCombo4.getSelectedItem().equals("Fanta")) {
priceLabel15.setText("0.95");
}
recalculate();
}
});
//Ice or not
String[] ice4 = {"Ice", "With Ice", "Without Ice"};
IceCombo4 = new JComboBox(ice4);
IceCombo4.setBounds(600, 180, 80, 30);
IceCombo4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (IceCombo4.getSelectedItem().equals("With Ice")) {
priceLabel16.setText("0.0");
} else if (IceCombo4.getSelectedItem().equals("WithoutIce")) {
priceLabel16.setText("0.0");
}
recalculate();
}
});
//comments field
CommentsField4 = new JTextField();
CommentsField4.setBounds(690, 180, 170, 30);
//Order 5
numberLabel5 = new JLabel();
numberLabel5.setBounds(10, 225, 200, 20);
numberLabel5.setText("Order 5");
//Pizza Combo box
String[] Pizza5 = {"Please select a Pizza", "Cheese and tomato", "Ham and Pineapple", "Vegetarian", "Meat Feast", "Seafood"};
PizzaCombo5 = new JComboBox(Pizza5);
PizzaCombo5.setBounds(75, 220, 150, 30);
PizzaCombo5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo5.getSelectedItem().equals("Cheese and tomato")) {
priceLabel17.setText("3.50");
} else if (PizzaCombo5.getSelectedItem().equals("Ham and Pineapple")) {
priceLabel17.setText("4.20");
} else if (PizzaCombo5.getSelectedItem().equals("Vegetarian")) {
priceLabel17.setText("5.20");
} else if (PizzaCombo5.getSelectedItem().equals("Meat Feast")) {
priceLabel17.setText("5.80");
} else if (PizzaCombo5.getSelectedItem().equals("Seafood")) {
priceLabel17.setText("5.60");
}
recalculate();
}
});
//Base Combo
String[] Base5 = {"Please select a Pizza Base", "Thin & Crispy", "Traditional", "Stuffed Crust", "Deep Pan", "Cheesey Bites"};
JComboBox PizzaBaseCombo5 = new JComboBox(Base5);
PizzaBaseCombo5.setBounds(235, 220, 195, 30);
PizzaBaseCombo5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo5.getSelectedItem().equals("Thin & Crispy")) {
priceLabel18.setText("0.0");
} else if (PizzaCombo5.getSelectedItem().equals("Traditional")) {
priceLabel18.setText("0.0");
} else if (PizzaCombo5.getSelectedItem().equals("Stuffed Crust")) {
priceLabel18.setText("0.0");
} else if (PizzaCombo5.getSelectedItem().equals("Deep Pan")) {
priceLabel18.setText("0.0");
} else if (PizzaCombo5.getSelectedItem().equals("Cheesey Bites")) {
priceLabel18.setText("0.0");
}
recalculate();
}
});
//Drinks Combo Box
String[] drinks5 = {"Please select a drink", "Cola", "Lemonade", "Fanta"};
DrinksCombo5 = new JComboBox(drinks5);
DrinksCombo5.setBounds(445, 220, 150, 30);
DrinksCombo5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (DrinksCombo5.getSelectedItem().equals("Cola")) {
priceLabel19.setText("0.90");
} else if (DrinksCombo5.getSelectedItem().equals("Lemonade")) {
priceLabel19.setText("0.95");
} else if (DrinksCombo5.getSelectedItem().equals("Fanta")) {
priceLabel19.setText("0.95");
}
recalculate();
}
});
//Ice or not
String[] ice5 = {"Ice", "With Ice", "Without Ice"};
IceCombo5 = new JComboBox(ice5);
IceCombo5.setBounds(600, 220, 80, 30);
IceCombo5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (IceCombo5.getSelectedItem().equals("With Ice")) {
priceLabel20.setText("0.0");
} else if (IceCombo5.getSelectedItem().equals("WithoutIce")) {
priceLabel20.setText("0.0");
}
recalculate();
}
});
//comments field
CommentsField5 = new JTextField();
CommentsField5.setBounds(690, 220, 170, 30);
//Order 6
numberLabel6 = new JLabel();
numberLabel6.setBounds(10, 265, 200, 20);
numberLabel6.setText("Order 6");
//Pizza Combo box
String[] Pizza6 = {"Please select a Pizza", "Cheese and tomato", "Ham and Pineapple", "Vegetarian", "Meat Feast", "Seafood"};
PizzaCombo6 = new JComboBox(Pizza6);
PizzaCombo6.setBounds(75, 260, 150, 30);
PizzaCombo6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo6.getSelectedItem().equals("Cheese and tomato")) {
priceLabel2l.setText("3.50");
} else if (PizzaCombo6.getSelectedItem().equals("Ham and Pineapple")) {
priceLabel2l.setText("4.20");
} else if (PizzaCombo6.getSelectedItem().equals("Vegetarian")) {
priceLabel2l.setText("5.20");
} else if (PizzaCombo6.getSelectedItem().equals("Meat Feast")) {
priceLabel2l.setText("5.80");
} else if (PizzaCombo6.getSelectedItem().equals("Seafood")) {
priceLabel2l.setText("5.60");
}
recalculate();
}
});
//Base Combo
String[] Base6 = {"Please select a Pizza Base", "Thin & Crispy", "Traditional", "Stuffed Crust", "Deep Pan", "Cheesey Bites"};
JComboBox PizzaBaseCombo6 = new JComboBox(Base4);
PizzaBaseCombo6.setBounds(235, 260, 195, 30);
PizzaBaseCombo6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo6.getSelectedItem().equals("Thin & Crispy")) {
priceLabel22.setText("0.0");
} else if (PizzaCombo6.getSelectedItem().equals("Traditional")) {
priceLabel22.setText("0.0");
} else if (PizzaCombo6.getSelectedItem().equals("Stuffed Crust")) {
priceLabel22.setText("0.0");
} else if (PizzaCombo6.getSelectedItem().equals("Deep Pan")) {
priceLabel22.setText("0.0");
} else if (PizzaCombo6.getSelectedItem().equals("Cheesey Bites")) {
priceLabel22.setText("0.0");
}
recalculate();
}
});
//Drinks Combo Box
String[] drinks6 = {"Please select a drink", "Cola", "Lemonade", "Fanta"};
DrinksCombo6 = new JComboBox(drinks4);
DrinksCombo6.setBounds(445, 260, 150, 30);
DrinksCombo6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (DrinksCombo6.getSelectedItem().equals("Cola")) {
priceLabel23.setText("0.90");
} else if (DrinksCombo6.getSelectedItem().equals("Lemonade")) {
priceLabel23.setText("0.95");
} else if (DrinksCombo6.getSelectedItem().equals("Fanta")) {
priceLabel23.setText("0.95");
}
recalculate();
}
});
//Ice or not
String[] ice6 = {"Ice", "With Ice", "Without Ice"};
IceCombo6 = new JComboBox(ice6);
IceCombo6.setBounds(600, 260, 80, 30);
IceCombo6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (IceCombo6.getSelectedItem().equals("With Ice")) {
priceLabel24.setText("0.0");
} else if (IceCombo6.getSelectedItem().equals("WithoutIce")) {
priceLabel24.setText("0.0");
}
recalculate();
}
});
//comments field
CommentsField6 = new JTextField();
CommentsField6.setBounds(690, 260, 170, 30);
//Order 7
numberLabel7 = new JLabel();
numberLabel7.setBounds(10, 305, 200, 20);
numberLabel7.setText("Order 7");
//Pizza Combo box
String[] Pizza7 = {"Please select a Pizza", "Cheese and tomato", "Ham and Pineapple", "Vegetarian", "Meat Feast", "Seafood"};
PizzaCombo7 = new JComboBox(Pizza7);
PizzaCombo7.setBounds(75, 300, 150, 30);
PizzaCombo7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo7.getSelectedItem().equals("Cheese and tomato")) {
priceLabel25.setText("3.50");
} else if (PizzaCombo7.getSelectedItem().equals("Ham and Pineapple")) {
priceLabel25.setText("4.20");
} else if (PizzaCombo7.getSelectedItem().equals("Vegetarian")) {
priceLabel25.setText("5.20");
} else if (PizzaCombo7.getSelectedItem().equals("Meat Feast")) {
priceLabel25.setText("5.80");
} else if (PizzaCombo7.getSelectedItem().equals("Seafood")) {
priceLabel25.setText("5.60");
}
recalculate();
}
});
//Base Combo
String[] Base7 = {"Please select a Pizza Base", "Thin & Crispy", "Traditional", "Stuffed Crust", "Deep Pan", "Cheesey Bites"};
JComboBox PizzaBaseCombo7 = new JComboBox(Base4);
PizzaBaseCombo7.setBounds(235, 300, 195, 30);
PizzaBaseCombo7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo7.getSelectedItem().equals("Thin & Crispy")) {
priceLabel26.setText("0.0");
} else if (PizzaCombo7.getSelectedItem().equals("Traditional")) {
priceLabel26.setText("0.0");
} else if (PizzaCombo7.getSelectedItem().equals("Stuffed Crust")) {
priceLabel26.setText("0.0");
} else if (PizzaCombo7.getSelectedItem().equals("Deep Pan")) {
priceLabel26.setText("0.0");
} else if (PizzaCombo7.getSelectedItem().equals("Cheesey Bites")) {
priceLabel26.setText("0.0");
}
recalculate();
}
});
//Drinks Combo Box
String[] drinks7 = {"Please select a drink", "Cola", "Lemonade", "Fanta"};
DrinksCombo7 = new JComboBox(drinks7);
DrinksCombo7.setBounds(445, 300, 150, 30);
DrinksCombo7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (DrinksCombo7.getSelectedItem().equals("Cola")) {
priceLabel27.setText("0.90");
} else if (DrinksCombo7.getSelectedItem().equals("Lemonade")) {
priceLabel27.setText("0.95");
} else if (DrinksCombo7.getSelectedItem().equals("Fanta")) {
priceLabel27.setText("0.95");
}
recalculate();
}
});
//Ice or not
String[] ice7 = {"Ice", "With Ice", "Without Ice"};
IceCombo7 = new JComboBox(ice7);
IceCombo7.setBounds(600, 300, 80, 30);
IceCombo7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (IceCombo7.getSelectedItem().equals("With Ice")) {
priceLabel28.setText("0.0");
} else if (IceCombo7.getSelectedItem().equals("WithoutIce")) {
priceLabel28.setText("0.0");
}
recalculate();
}
});
//comments field
CommentsField7 = new JTextField();
CommentsField7.setBounds(690, 300, 170, 30);
//Order 8
numberLabel8 = new JLabel();
numberLabel8.setBounds(10, 345, 200, 20);
numberLabel8.setText("Order 8");
//Pizza Combo box
String[] Pizza8 = {"Please select a Pizza", "Cheese and tomato", "Ham and Pineapple", "Vegetarian", "Meat Feast", "Seafood"};
PizzaCombo8 = new JComboBox(Pizza4);
PizzaCombo8.setBounds(75, 340, 150, 30);
PizzaCombo8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo8.getSelectedItem().equals("Cheese and tomato")) {
priceLabel29.setText("3.50");
} else if (PizzaCombo8.getSelectedItem().equals("Ham and Pineapple")) {
priceLabel29.setText("4.20");
} else if (PizzaCombo8.getSelectedItem().equals("Vegetarian")) {
priceLabel29.setText("5.20");
} else if (PizzaCombo8.getSelectedItem().equals("Meat Feast")) {
priceLabel29.setText("5.80");
} else if (PizzaCombo8.getSelectedItem().equals("Seafood")) {
priceLabel29.setText("5.60");
}
recalculate();
}
});
//Base Combo
String[] Base8 = {"Please select a Pizza Base", "Thin & Crispy", "Traditional", "Stuffed Crust", "Deep Pan", "Cheesey Bites"};
JComboBox PizzaBaseCombo8 = new JComboBox(Base8);
PizzaBaseCombo8.setBounds(235, 340, 195, 30);
PizzaBaseCombo8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo8.getSelectedItem().equals("Thin & Crispy")) {
priceLabel30.setText("0.0");
} else if (PizzaCombo8.getSelectedItem().equals("Traditional")) {
priceLabel30.setText("0.0");
} else if (PizzaCombo8.getSelectedItem().equals("Stuffed Crust")) {
priceLabel30.setText("0.0");
} else if (PizzaCombo8.getSelectedItem().equals("Deep Pan")) {
priceLabel30.setText("0.0");
} else if (PizzaCombo8.getSelectedItem().equals("Cheesey Bites")) {
priceLabel30.setText("0.0");
}
recalculate();
}
});
//Drinks Combo Box
String[] drinks8 = {"Please select a drink", "Cola", "Lemonade", "Fanta"};
DrinksCombo8 = new JComboBox(drinks8);
DrinksCombo8.setBounds(445, 340, 150, 30);
DrinksCombo8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (DrinksCombo8.getSelectedItem().equals("Cola")) {
priceLabel31.setText("0.90");
} else if (DrinksCombo8.getSelectedItem().equals("Lemonade")) {
priceLabel31.setText("0.95");
} else if (DrinksCombo8.getSelectedItem().equals("Fanta")) {
priceLabel31.setText("0.95");
}
recalculate();
}
});
//Ice or not
String[] ice8 = {"Ice", "With Ice", "Without Ice"};
IceCombo8 = new JComboBox(ice8);
IceCombo8.setBounds(600, 340, 80, 30);
IceCombo8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (IceCombo8.getSelectedItem().equals("With Ice")) {
priceLabel32.setText("0.0");
} else if (IceCombo8.getSelectedItem().equals("WithoutIce")) {
priceLabel32.setText("0.0");
}
recalculate();
}
});
//comments field
CommentsField8 = new JTextField();
CommentsField8.setBounds(690, 340, 170, 30);
//Order 9
numberLabel9 = new JLabel();
numberLabel9.setBounds(10, 385, 200, 20);
numberLabel9.setText("Order 9");
//Pizza Combo box
String[] Pizza9 = {"Please select a Pizza", "Cheese and tomato", "Ham and Pineapple", "Vegetarian", "Meat Feast", "Seafood"};
PizzaCombo9 = new JComboBox(Pizza9);
PizzaCombo9.setBounds(75, 380, 150, 30);
PizzaCombo9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo9.getSelectedItem().equals("Cheese and tomato")) {
priceLabel33.setText("3.50");
} else if (PizzaCombo9.getSelectedItem().equals("Ham and Pineapple")) {
priceLabel33.setText("4.20");
} else if (PizzaCombo9.getSelectedItem().equals("Vegetarian")) {
priceLabel33.setText("5.20");
} else if (PizzaCombo9.getSelectedItem().equals("Meat Feast")) {
priceLabel33.setText("5.80");
} else if (PizzaCombo9.getSelectedItem().equals("Seafood")) {
priceLabel33.setText("5.60");
}
recalculate();
}
});
//Base Combo
String[] Base9 = {"Please select a Pizza Base", "Thin & Crispy", "Traditional", "Stuffed Crust", "Deep Pan", "Cheesey Bites"};
JComboBox PizzaBaseCombo9 = new JComboBox(Base9);
PizzaBaseCombo9.setBounds(235, 380, 195, 30);
PizzaBaseCombo9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo9.getSelectedItem().equals("Thin & Crispy")) {
priceLabel34.setText("0.0");
} else if (PizzaCombo9.getSelectedItem().equals("Traditional")) {
priceLabel34.setText("0.0");
} else if (PizzaCombo9.getSelectedItem().equals("Stuffed Crust")) {
priceLabel34.setText("0.0");
} else if (PizzaCombo9.getSelectedItem().equals("Deep Pan")) {
priceLabel34.setText("0.0");
} else if (PizzaCombo9.getSelectedItem().equals("Cheesey Bites")) {
priceLabel34.setText("0.0");
}
recalculate();
}
});
//Drinks Combo Box
String[] drinks9 = {"Please select a drink", "Cola", "Lemonade", "Fanta"};
DrinksCombo9 = new JComboBox(drinks9);
DrinksCombo9.setBounds(445, 380, 150, 30);
DrinksCombo9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (DrinksCombo9.getSelectedItem().equals("Cola")) {
priceLabel35.setText("0.90");
} else if (DrinksCombo9.getSelectedItem().equals("Lemonade")) {
priceLabel35.setText("0.95");
} else if (DrinksCombo9.getSelectedItem().equals("Fanta")) {
priceLabel35.setText("0.95");
}
recalculate();
}
});
//Ice or not
String[] ice9 = {"Ice", "With Ice", "Without Ice"};
IceCombo9 = new JComboBox(ice9);
IceCombo9.setBounds(600, 380, 80, 30);
IceCombo9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (IceCombo9.getSelectedItem().equals("With Ice")) {
priceLabel36.setText("0.0");
} else if (IceCombo9.getSelectedItem().equals("WithoutIce")) {
priceLabel36.setText("0.0");
}
recalculate();
}
});
//comments field
CommentsField9 = new JTextField();
CommentsField9.setBounds(690, 380, 170, 30);
//Order 10
numberLabel10 = new JLabel();
numberLabel10.setBounds(10, 425, 200, 20);
numberLabel10.setText("Order 10");
//Pizza Combo box
String[] Pizza10 = {"Please select a Pizza", "Cheese and tomato", "Ham and Pineapple", "Vegetarian", "Meat Feast", "Seafood"};
PizzaCombo10 = new JComboBox(Pizza10);
PizzaCombo10.setBounds(75, 420, 150, 30);
PizzaCombo10.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo10.getSelectedItem().equals("Cheese and tomato")) {
priceLabel37.setText("3.50");
} else if (PizzaCombo10.getSelectedItem().equals("Ham and Pineapple")) {
priceLabel37.setText("4.20");
} else if (PizzaCombo10.getSelectedItem().equals("Vegetarian")) {
priceLabel37.setText("5.20");
} else if (PizzaCombo10.getSelectedItem().equals("Meat Feast")) {
priceLabel37.setText("5.80");
} else if (PizzaCombo10.getSelectedItem().equals("Seafood")) {
priceLabel37.setText("5.60");
}
recalculate();
}
});
//Base Combo
String[] Base10 = {"Please select a Pizza Base", "Thin & Crispy", "Traditional", "Stuffed Crust", "Deep Pan", "Cheesey Bites"};
JComboBox PizzaBaseCombo10 = new JComboBox(Base10);
PizzaBaseCombo10.setBounds(235, 420, 195, 30);
PizzaBaseCombo10.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (PizzaCombo10.getSelectedItem().equals("Thin & Crispy")) {
priceLabel38.setText("0.0");
} else if (PizzaCombo10.getSelectedItem().equals("Traditional")) {
priceLabel38.setText("0.0");
} else if (PizzaCombo10.getSelectedItem().equals("Stuffed Crust")) {
priceLabel38.setText("0.0");
} else if (PizzaCombo10.getSelectedItem().equals("Deep Pan")) {
priceLabel38.setText("0.0");
} else if (PizzaCombo10.getSelectedItem().equals("Cheesey Bites")) {
priceLabel38.setText("0.0");
}
recalculate();
}
});
//Drinks Combo Box
String[] drinks10 = {"Please select a drink", "Cola", "Lemonade", "Fanta"};
DrinksCombo10 = new JComboBox(drinks10);
DrinksCombo10.setBounds(445, 420, 150, 30);
DrinksCombo10.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (DrinksCombo10.getSelectedItem().equals("Cola")) {
priceLabe139.setText("0.90");
} else if (DrinksCombo10.getSelectedItem().equals("Lemonade")) {
priceLabe139.setText("0.95");
} else if (DrinksCombo10.getSelectedItem().equals("Fanta")) {
priceLabe139.setText("0.95");
}
recalculate();
}
});
//Ice or not
String[] ice10 = {"Ice", "With Ice", "Without Ice"};
IceCombo10 = new JComboBox(ice10);
IceCombo10.setBounds(600, 420, 80, 30);
IceCombo10.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (IceCombo10.getSelectedItem().equals("With Ice")) {
priceLabel40.setText("0.0");
} else if (IceCombo10.getSelectedItem().equals("WithoutIce")) {
priceLabel40.setText("0.0");
}
recalculate();
}
});
//comments field
CommentsField10 = new JTextField();
CommentsField10.setBounds(690, 420, 170, 30);
//To Add items to the panel
panel.add(PizzaShackWidget);
panel.add(subtotalLabel);
panel.add(totalLabel);
panel.add(TableList);
panel.add(CommentsLabel);
panel.add(priceLabel2);
panel.add(DrinksCombo1);
panel.add(PizzaCombo1);
panel.add(numberLabel1);
panel.add(PizzaBaseCombo1);
panel.add(IceCombo1);
panel.add(CommentsField1);
panel.add(DrinksCombo2);
panel.add(PizzaCombo2);
panel.add(numberLabel2);
panel.add(PizzaBaseCombo2);
panel.add(IceCombo2);
panel.add(CommentsField2);
panel.add(DrinksCombo3);
panel.add(PizzaCombo3);
panel.add(numberLabel3);
panel.add(PizzaBaseCombo3);
panel.add(IceCombo3);
panel.add(CommentsField3);
panel.add(DrinksCombo4);
panel.add(PizzaCombo4);
panel.add(numberLabel4);
panel.add(PizzaBaseCombo4);
panel.add(IceCombo4);
panel.add(CommentsField4);
panel.add(DrinksCombo5);
panel.add(PizzaCombo5);
panel.add(numberLabel5);
panel.add(PizzaBaseCombo5);
panel.add(IceCombo5);
panel.add(CommentsField5);
panel.add(DrinksCombo6);
panel.add(PizzaCombo6);
panel.add(numberLabel6);
panel.add(PizzaBaseCombo6);
panel.add(IceCombo6);
panel.add(CommentsField6);
panel.add(DrinksCombo7);
panel.add(PizzaCombo7);
panel.add(numberLabel7);
panel.add(PizzaBaseCombo7);
panel.add(IceCombo7);
panel.add(CommentsField7);
panel.add(DrinksCombo8);
panel.add(PizzaCombo8);
panel.add(numberLabel8);
panel.add(PizzaBaseCombo8);
panel.add(IceCombo8);
panel.add(CommentsField8);
panel.add(DrinksCombo9);
panel.add(PizzaCombo9);
panel.add(numberLabel9);
panel.add(PizzaBaseCombo9);
panel.add(IceCombo9);
panel.add(CommentsField9);
panel.add(DrinksCombo10);
panel.add(PizzaCombo10);
panel.add(numberLabel10);
panel.add(PizzaBaseCombo10);
panel.add(IceCombo10);
panel.add(CommentsField10);
}
private void recalculate() {
// recalculate subTotal
double price;
// int quantity;
double subtotal;
double total;
String subtotalOutput;
String totalOutput;
NumberFormat subtotalFormat;
NumberFormat totalFormat;
price = Double.parseDouble(priceLabel.getText());
subtotal = price;
//Formating numbers
subtotalFormat = NumberFormat.getNumberInstance();
subtotalOutput = String.valueOf(subtotal) + subtotalFormat.format(0.00);
subtotalLabel.setText(subtotalOutput);
// now recalculate total
total = Double.parseDouble(subtotalLabel.getText());
// NOTE: if you have many subtotal labels get the
// text from each one using:
// total = Double.parseDouble(subtotalLabelOne.getText())
// + Double.parseDouble(subtotalLabelTwo.getText());
totalFormat = NumberFormat.getCurrencyInstance(Locale.UK);
totalOutput = totalFormat.format(total);
totalLabel.setText(totalOutput);
}
/**
*
* @param args
*/
public static void main(String[] args) {
// TODO code application logic here
OrderingSystem gui = new OrderingSystem();
gui.setVisible(true);
}
}