am doing my project right now..
can u help me with my errors??
the errors: cannot find symbol getLabel and setState(boolean).
package PizzaOrderForm;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
public class PizzaOrderForm extends JFrame implements ActionListener, ItemListener{
int price=0;
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"};
String string1=new String();
String string2=new String();
String string3=new String();
String string4=new String();
String string5=new String();
String temp= new String();
String hold = new String();
public static void main(String args[]){
PizzaOrderForm pizza = new PizzaOrderForm();
pizza.createPizzaForm();
}
public void createPizzaForm(){
setTitle("PIZZA ORDER FORM");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setResizable(false);
setLocationRelativeTo(null);
mainPanel.setEnabled(false);
mainPanel = new JPanel(new BorderLayout());
mainPanel.setBackground(Color.black);
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());
//=====first panel=========
quantity = new JLabel("QUANTITY: ");
num1 = new JComboBox(num);
num1.setForeground(Color.green);
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: ");
//=====second panel=======
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(pizcrust[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]);
}
//=======third panel==========
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);
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.addActionListener(this);
reset.addActionListener(this);
add.addActionListener(this);
add(mainPanel);
pack();
setVisible(true);
}
public void itemStateChanged(ItemEvent e)
{
// QUANTITY-------------------------------------------------------------------------------------
if(e.getSource()==num1)
{
if(e.getStateChange()==e.SELECTED)
{
string1=" "+num1.getItemAt(num1.getSelectedIndex()).toString();
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(temp);
summary.append(hold);
}
}
// SIZE-----------------------------------------------------------------------------------------
if(e.getSource()==pizsize[0])
{
price=400;
string2="\t "+String.valueOf(price);
string3="\t\t"+pizsize[0].getLabel();
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
if(e.getSource()==pizsize[1])
{
price=500;
string2="\t "+String.valueOf(price);
string3="\t\t"+pizsize[1].getLabel();
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
if(e.getSource()==pizsize[2])
{
price=600;
string2="\t "+String.valueOf(price);
string3="\t\t"+pizsize[2].getLabel();
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
if(e.getSource()==pizsize[3])
{
price=700;
string2="\t "+String.valueOf(price);
string3="\t\tFS";
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
// TOPPINGS--------------------------------------------------------------------------------------
if(e.getSource()==piztop[0])
{
if(e.getStateChange()==e.SELECTED)
{
price=price+5;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
else
{
price=price-5;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
}
if(e.getSource()==piztop[2])
{
if(e.getStateChange()==e.SELECTED)
{
price=price+10;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
else
{
price=price-10;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
}
if(e.getSource()==piztop[3])
{
if(e.getStateChange()==e.SELECTED)
{
price=price+15;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
else
{
price=price-15;
String price1=String.valueOf(price);
string1="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
}
if(e.getSource()==piztop[4])
{
if(e.getStateChange()==e.SELECTED)
{
price=price+20;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
else
{
price=price-20;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
}
if(e.getSource()==piztop[4])
{
if(e.getStateChange()==e.SELECTED)
{
price=price+30;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
else
{
price=price-30;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
}
if(e.getSource()==piztop[5])
{
if(e.getStateChange()==e.SELECTED)
{
price=price+40;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
else
{
price=price-40;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
}
if(e.getSource()==piztop[6])
{
if(e.getStateChange()==e.SELECTED)
{
price=price+50;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
else
{
price=price-50;
String price1=String.valueOf(price);
string2="\t "+price1;
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
}
// CRUST-----------------------------------------------------------------------------------------
if(e.getSource()==pizcrust[0])
{
string4=" "+pizcrust[0].getLabel();
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
if(e.getSource()==pizcrust[1])
{
string4=" "+pizcrust[1].getLabel()+" ";
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
if(e.getSource()==pizcrust[2])
{
string4=" "+pizcrust[2].getLabel()+" ";
temp=string1+string2+string3+string4;
summary.setText("");
summary.append(hold);
summary.append(temp);
}
// DISCOUNT--------------------------------------------------------------------------------------
if(e.getSource()==pizdis[0])
{
rate.setEditable(true);
}
if(e.getSource()==pizdis[1])
{
rate.setEditable(false);
}
}
public void actionPerformed(ActionEvent e)
{
String action=e.getActionCommand();
if(action.equals("Add"))
{
int qty=num1.getSelectedIndex();
int subtotal=qty*price;
String strstr=String.valueOf(subtotal);
string5="\t"+strstr;
temp=string1+string2+string3+string4+string5;
summary.append(string5);
hold+=temp+"\n";
if(pizdis[0].getState()==true)
{
double discount1=Double.parseDouble(rate.getText());
double discount2=discount1/100;
double discount3=discount2*subtotal;
double total=subtotal-discount3;
String result=String.valueOf(total);
toAmnt.setText(result);
}
else if(pizdis[0].getState()==false)
{
String result2=String.valueOf(subtotal);
toAmnt.setText(result2);
}
price=0;
temp="";
string1="";
string2="";
string3="";
string4="";
string5="";
num1.setSelectedIndex(0);
pizsize[0].setState(false);
pizsize[1].setState(false);
pizsize[2].setState(false);
pizsize[3].setState(false);
piztop[0].setState(false);
piztop[1].setState(false);
piztop[2].setState(false);
piztop[3].setState(false);
piztop[4].setState(false);
piztop[5].setState(false);
piztop[6].setState(false);
pizcrust[0].setState(false);
pizcrust[1].setState(false);
pizcrust[2].setState(false);
pizdis[0].setState(false);
pizdis[1].setState(true);
rate.setEditable(false);
rate.setText("");
tenAmnt.setText("");
change.setText("");
}
else if(action.equalsIgnoreCase("Reset"))
{
price=0;
temp="";
hold="";
string1="";
string2="";
string3="";
string4="";
string5="";
num1.setSelectedIndex(0);
pizsize[0].setState(false);
pizsize[1].setState(false);
pizsize[2].setState(false);
pizsize[3].setState(false);
piztop[0].setState(false);
piztop[1].setState(false);
piztop[2].setState(false);
piztop[3].setState(false);
piztop[4].setState(false);
piztop[5].setState(false);
piztop[6].setState(false);
pizcrust[0].setState(false);
pizcrust[1].setState(false);
pizcrust[2].setState(false);
pizdis[0].setState(false);
pizdis[1].setState(true);
rate.setEditable(false);
rate.setText("");
tenAmnt.setText("");
change.setText("");
toAmnt.setText("");
summary.setText("");
}
else if(e.getSource()==tenAmnt)
{
double a=Double.parseDouble(toAmnt.getText());
double b=Double.parseDouble(tenAmnt.getText());
if(b>=a)
{
double flag=b-a;
String resultamount=String.valueOf(flag);
change.setText(resultamount);
}
else if(b<a)
{
JOptionPane.showMessageDialog(null,"WRONG AMOUNT!",JOptionPane.WARNING_MESSAGE);
}
}
}
}

New Topic/Question
Reply



MultiQuote




|