package PizzaOrderForm;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PizzaOrderForm extends JFrame implements ActionListener{
int totalAmount,orderChange;
JPanel mainPanel;
JPanel top1Panel,top2Panel,topPanel;
JPanel centerPanel,center1Panel,center2Panel,center3Panel;
JPanel lowerPanel,northPanel,cntrPanel,southPanel,north1,north2,south1,south2,south3;
JCheckBox[] pizzaCrust,pizzaTopping;
JRadioButton[] pizzaSize,pizzaDiscount;
JLabel quantity,box,top,size,ify,rt,amnt1,amnt2,sum,crust,discount,amntChnge;
JComboBox num1;
JTextField rate, toAmnt,tenAmnt,change;
JTextArea summary;
JButton reset,add;
JScrollPane scroll;
String[] num={"1","2","3","4","5","6","7","8","9","10","11","12"};
String[] pizsize = {"Small","Medium","Large","Family size"};
String[] piztop = {"Sausage","Pepperoni","Cheese","Hamburger","Olives","Mushrooms","PineApples"};
String[] pizcrust= {"Hand-tossed","Thin-crust","Deep dish"};
String[] pizdis = {"Yes","No"};
public void createPizzaForm(){
setTitle("PIZZA ORDER FORM");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setResizable(false);
setLocationRelativeTo(null);
mainPanel = new JPanel(new BorderLayout());
top1Panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
top2Panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
topPanel = new JPanel(new BorderLayout());
centerPanel = new JPanel(new BorderLayout());
center1Panel= new JPanel(new GridLayout(4,2));
center2Panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
center3Panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
north1 = new JPanel(new FlowLayout(FlowLayout.CENTER) );
north2 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
northPanel = new JPanel(new BorderLayout());
cntrPanel = new JPanel(new BorderLayout());
southPanel = new JPanel(new BorderLayout());
lowerPanel = new JPanel(new BorderLayout());
quantity = new JLabel("QUANTITY: ");
num1 = new JComboBox(num);
num1.setSelectedIndex(0);
box= new JLabel("Box(es)");
top1Panel.add(quantity);
top1Panel.add(num1);
top1Panel.add(box);
size =new JLabel("SIZES: ");
top2Panel.add(size);
top = new JLabel("TOPPINGS: ");
ButtonGroup groupSize = new ButtonGroup();
pizzaSize = new JRadioButton[pizsize.length];
for(int x=0;x<pizsize.length;x++){
pizzaSize[x]= new JRadioButton(pizsize[x]);
groupSize.add(pizzaSize[x]);
top2Panel.add(pizzaSize[x]);
}
pizzaTopping = new JCheckBox[piztop.length];
for(int x=0;x<piztop.length;x++){
center1Panel.add(new JLabel(piztop[x]));
pizzaTopping[x] = new JCheckBox();
center1Panel.add(pizzaTopping[x]);
}
crust= new JLabel("CRUST: ");
center2Panel.add(crust);
pizzaCrust = new JCheckBox[pizcrust.length];
for(int x=0;x<pizcrust.length;x++){
center2Panel.add(new JLabel(piztop[x]));
pizzaCrust[x] = new JCheckBox();
center2Panel.add(pizzaCrust[x]);
}
discount= new JLabel("Discount? ");
center3Panel.add(discount);
ButtonGroup groupDiscount = new ButtonGroup();
pizzaDiscount = new JRadioButton[pizdis.length];
for(int x=0;x<pizdis.length;x++){
pizzaDiscount[x]= new JRadioButton(pizdis[x]);
groupDiscount.add(pizzaDiscount[x]);
center3Panel.add(pizzaDiscount[x]);
}
ify= new JLabel("If yes, ");
rate= new JTextField(5);
rt= new JLabel("%");
north1.add(ify);
north1.add(rate);
north1.add(rt);
reset= new JButton("RESET"); reset.setBackground(Color.red);
add= new JButton("ADD"); add.setBackground(Color.red);
north2.add(reset);
north2.add(add);
sum= new JLabel("QTY / SIZE / CRUST / PRICE / SUBTOTAL");
summary = new JTextArea(5,30);
summary.setLineWrap(true);
summary.setWrapStyleWord(true);
scroll = new JScrollPane(summary);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
getContentPane().add(scroll);
amnt1 = new JLabel("Total Amount");
amnt2 = new JLabel("Tendered Amount");
amntChnge = new JLabel("Change");
toAmnt= new JTextField(10);
tenAmnt= new JTextField(10);
change= new JTextField(10);
south1 =new JPanel(new FlowLayout(FlowLayout.RIGHT));
south2 = new JPanel (new FlowLayout(FlowLayout.RIGHT));
south3 = new JPanel (new FlowLayout(FlowLayout.RIGHT));
cntrPanel.add(sum,BorderLayout.NORTH);
cntrPanel.add(summary,BorderLayout.CENTER);
cntrPanel.add(scroll,BorderLayout.EAST);
south1.add(amnt1);
south1.add(toAmnt);
south2.add(amnt2);
south2.add(tenAmnt);
south3.add(amntChnge);
south3.add(change);
topPanel.add(top1Panel,BorderLayout.NORTH);
topPanel.add(top2Panel,BorderLayout.CENTER);
topPanel.add(top,BorderLayout.SOUTH);
centerPanel.add(center3Panel,BorderLayout.SOUTH);
centerPanel.add(center2Panel,BorderLayout.CENTER);
centerPanel.add(center1Panel,BorderLayout.NORTH);
northPanel.add(north1,BorderLayout.NORTH);
northPanel.add(north2,BorderLayout.EAST);
southPanel.add(south1,BorderLayout.NORTH);
southPanel.add(south2,BorderLayout.CENTER);
southPanel.add(south3,BorderLayout.SOUTH);
lowerPanel.add(northPanel,BorderLayout.NORTH);
lowerPanel.add(cntrPanel,BorderLayout.CENTER);
lowerPanel.add(southPanel,BorderLayout.SOUTH);
mainPanel.add(topPanel,BorderLayout.NORTH);
mainPanel.add(centerPanel,BorderLayout.CENTER);
mainPanel.add(lowerPanel,BorderLayout.SOUTH);
num1.addActinonListener(this);
reset.addActionListener(this);
add.addActionListener(this);
add(mainPanel);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
Object cbox = e.getSource();
if(cbox==reset){
}
else if(cbox==add){
}
}
public static void main(String args[]){
PizzaOrderForm pizza = new PizzaOrderForm();
pizza.createPizzaForm();
}
}
/**System.out.println("Order button has been pressed");
for(int i = 0; i < toppings.length; i++)
System.out.println(toppingList[i] + " is " + toppings[i].isSelected());
System.out.println("Quantity is " + (quantity.getSelectedIndex() + 1));
if(ch==add){
i++;
text.setText(Integer.toString(i));
if(i>=10){
JOptionPane.showMessageDialog(this,"Reach maximum value of 10.");
}
}*/
hi.. can you help me.. am still confuse on what kind of implementation i should use for the reset and add button..
hope you could help me..tnx..

New Topic/Question
Reply


MultiQuote




|