Results 1 to 4 of 4
  1. #1
    GabWit is offline Member
    Join Date
    Jan 2009
    Posts
    11
    Rep Power
    0

    Default cannot find symbol

    i have 2 errors saying cannot find symbol

    Anything in red is the error



    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;

    public class eBusiness extends Applet implements ActionListener, ItemListener
    {
    Panel pnlTitle= new Panel ();
    Panel pnlTextField = new Panel ();
    Panel pnlCheckbox = new Panel ();
    Panel pnlOption = new Panel ();
    Panel pnlOutput = new Panel ();
    Panel pnlOutput2 = new Panel ();
    Panel pnlStuff = new Panel ();

    final double dblPencilPrice = 1.00;
    final double dblPenPrice = 1.00;

    String strName;
    String strAddress;
    String strEmail;
    String strPhoneNumber;
    String strCellPhoneNumber;

    double dblPencilTotal;
    double dblPenTotal;
    double dblEraserTotal;
    double dblStaplerTotal;
    double dblRulerTotal;
    double dblPaperClipsTotal;
    double dblCalculatorTotal;
    double dblSharpenerTotal;
    double dblHighlighterTotal;
    double dblMarkersTotal;
    double dblTotal;
    double dblTax2;
    double dblFinalTotal;

    int intPencilCounter = 0;
    int intPenCounter = 0;
    int intEraserCounter = 0;
    int intStaplerCounter = 0;
    int intRulerCounter = 0;
    int intPaperClipsCounter = 0;
    int intCalculatorCounter = 0;
    int intSharpenerCounter = 0;
    int intHighlighterCounter = 0;
    int intMarkersCounter = 0;
    int intTotalCounter = 0;
    int intImageStapler = 0;

    TextField txtName = new TextField (15);
    TextField txtAddress = new TextField (30);
    TextField txtEmail = new TextField (20);
    TextField txtPhoneNumber = new TextField (10);
    TextField txtCellNumber = new TextField (10);

    Checkbox chkPencil = new Checkbox ("6 Pencils- $1.00");
    Checkbox chkPen = new Checkbox ("Pen- $1.00");

    CheckboxGroup cbgPayment = new CheckboxGroup ();
    Checkbox optCash = new Checkbox ("Cash", cbgPayment, false);
    Checkbox optCheque = new Checkbox ("Cheque", cbgPayment, false);
    Checkbox optVISA = new Checkbox ("Visa", cbgPayment, false);
    Checkbox optMasterCard = new Checkbox ("MasterCard", cbgPayment, false);
    Checkbox optAMEX = new Checkbox ("AMEX", cbgPayment, false);

    Button btnBuy = new Button("BUY");
    Button btnClear = new Button("CLEAR");
    Button btnExit = new Button("EXIT");

    TextArea txaUserInformation = new TextArea (10,25);
    TextArea txaUserThings = new TextArea (10,25);

    Label lblPayment = new Label ("");
    Label lblItem = new Label ("");
    Label lblTotal = new Label ("");
    Label lblTax = new Label ("");
    Label lblFinalTotal = new Label ("");

    Font fntSetting = new Font ("Arial",Font.BOLD,50);
    Font fntSetting2 = new Font ("Arial",Font.BOLD,12);

    public void init()
    {

    setBackground(Color.black);

    add (pnlStuff);
    add (pnlTitle);
    add (pnlTextField);
    add (pnlCheckbox);
    add (pnlOption);
    add (pnlStuff);
    add (pnlOutput);
    add (pnlOutput2);

    pnlStuff.setBackground(Color.gray);
    pnlStuff.setLayout(new GridLayout(2,1));
    pnlStuff.add (new Label("ROW1 "));
    pnlStuff.add(new Label("ROW2 "));

    pnlTitle.setBackground(Color.yellow);
    pnlTitle.setLayout(new GridLayout(1,1));
    pnlTitle.add(new Label(" The Soccer Snop "));
    pnlTitle.setFont(fntSetting);

    pnlTextField.setBackground(Color.pink);
    pnlTextField.setLayout(new GridLayout(6,2));
    pnlTextField.add(new Label("Please enter yout information"));
    pnlTextField.add(new Label(""));
    pnlTextField.add(new Label("Name: "));
    txtName.setForeground(Color.cyan);
    txtName.setBackground(Color.black);

    pnlTextField.add(txt.Name);
    pnlTextField.add(new Label("Address: "));
    pnlTextField.add(txt.Address);

    pnlTextField.setFont(fntSetting2);

    pnlCheckbox.setBackground(Color.white);
    pnlCheckbox.setLayout(new GridLayout(11,1));
    pnlCheckbox.add(new Label("Please choose the item that you would like to buy"));
    pnlCheckbox.add(chkPencil);
    pnlCheckbox.add(chkPen);

    pnlCheckbox.setFont(fntSetting2);

    pnlOption.setBackground(Color.white);
    pnlOption.setLayout(new GridLayout(9,1));
    pnlOption.add(new Label("How do you want to pay"));
    pnlOption.add(optCash);
    pnlOption.add(optCheque);
    pnlOption.add(optMasterCard);
    pnlOption.add(optVISA);
    pnlOption.add(optAMEX);

    pnlOption.add(btnBuy);
    pnlOption.add(btnClear);
    pnlOption.add(btnExit);
    pnlOption.setFont(fntSetting2);

    pnlOutput.setBackground(Color.white);
    pnlOutput.setLayout(new GridLayout(2,2));
    pnlOutput.add(new Label("Your information"));
    pnlOutput.add(new Label("Items you want to buy"));
    pnlOutput.add(txaUserInformation);
    pnlOutput.add(txaUserThings);
    pnlOutput.setFont(fntSetting2);

    pnlOutput2.setBackground(Color.white);
    pnlOutput2.setLayout(new GridLayout(5,2));
    pnlOutput2.add(new Label("Option of payment"));
    pnlOutput2.add(lblPayment);
    pnlOutput2.add(new Label("Total number of items"));
    pnlOutput2.add(lblItem);
    pnlOutput2.add(new Label("Total"));
    pnlOutput2.add(lblTotal);
    pnlOutput2.add(new Label("Tax"));
    pnlOutput2.add(lblTax);
    pnlOutput2.add(new Label("Final Total"));
    pnlOutput2.add(lblFinalTotal);
    pnlOutput2.setFont(fntSetting2);

    txtName.addActionListener(this);
    txtAddress.addActionListener(this);
    txtEmail.addActionListener(this);
    txtPhoneNumber.addActionListener(this);
    btnBuy.addActionListener(this);
    btnClear.addActionListener(this);
    btnExit.addActionListener(this);

    chkPencil.addItemListener(this);
    chkPen.addItemListener(this);

    optCash.addItemListener(this);
    optCheque.addItemListener(this);
    optVISA.addItemListener(this);
    optMasterCard.addItemListener(this);
    optAMEX.addItemListener(this);

    }

    public void actionPerformed(ActionEvent event)
    {
    if (event.getSource()instanceof Button)
    {
    if (event.getSource()== btnBuy)
    {
    strName=txtName.getText();
    strAddress=txtAddress.getText();

    txaUserInformation.append("Name:" + strName + "\n" + "Address:" + strAddress + "\n" + "E-mail:" + strEmail + "\n" + "Phone Number:" + strPhoneNumber);

    dblTotal = dblPencilTotal + dblPenTotal + dblEraserTotal + dblStaplerTotal +
    dblRulerTotal + dblPaperClipsTotal + dblCalculatorTotal + dblSharpenerTotal + dblHighlighterTotal +
    dblMarkersTotal;
    lblTotal.setText("");
    lblTotal.setText("$" + dblFinalTotal);
    }
    if(event.getSource()==btnClear)
    {
    txaUserInformation.setText("");
    txaUserThings.setText("");
    txtName.setText("");
    txtAddress.setText("");
    txtEmail.setText("");
    txtPhoneNumber.setText("");
    lblPayment.setText("");
    lblItem.setText("");
    lblTotal.setText("");
    lblTax.setText("");
    lblFinalTotal.setText("");
    intTotalCounter=0;
    intPencilCounter=0;
    intPenCounter=0;
    intEraserCounter=0;
    intStaplerCounter=0;
    intTotalCounter=0;
    intRulerCounter=0;
    intPaperClipsCounter=0;
    intCalculatorCounter=0;
    intSharpenerCounter=0;
    intHighlighterCounter=0;
    intMarkersCounter=0;
    txtName.requestFocus();
    }
    if(event.getSource()==btnExit)
    {
    System.exit(0);
    }
    }
    }
    public void itemStateChanged(ItemEvent it)
    {

    if(it.getSource()==chkPencil)
    {

    intPencilCounter += 1;
    dblPencilTotal=dblPencilPrice*intPencilCounter;
    txaUserThings.setText("Pencils price: $" + dblPencilTotal +"\nNumber of pencils ordered "
    + intPencilCounter + "\n" + "\n");
    }

    intTotalCounter = intPencilCounter + intPenCounter + intEraserCounter + intStaplerCounter +
    intRulerCounter + intPaperClipsCounter + intCalculatorCounter + intSharpenerCounter +
    intHighlighterCounter + intMarkersCounter;
    lblItem.setText("");
    lblItem.setText(""+intTotalCounter);

    if(it.getSource()==optCash)
    {
    lblPayment.setText("");
    lblPayment.setText("CASH");
    }
    }
    }
    Last edited by GabWit; 01-25-2009 at 12:10 AM.

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    you declare pnlTextfield, and use pnlTextField.

    And in this Statement
    Java Code:
    txaUserInformation.append("Name:"= + strName + "\n" + "Address:" + strAddress + "\n" + "E-mail:" + strEmail + "\n" + "Phone Number:" + strPhoneNumber);
    The equals sign (=) is your problem.

    For the others, you are using setBackround(Color) instead of setBackground(Color)

  3. #3
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default This is easy...

    Listen... don't freak out with the amount of errors. Most are real easy to fix...
    for example... the "setBackround" errors are because of a typo... it's "setBackground".
    the "txt.Name" error is because it should be "txtName".
    Review the errors with care and look at your code and you can figure out the errors yourself.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  4. #4
    GabWit is offline Member
    Join Date
    Jan 2009
    Posts
    11
    Rep Power
    0

Similar Threads

  1. java:34:cannot find symbol
    By MissyMadi in forum New To Java
    Replies: 5
    Last Post: 11-09-2008, 06:53 PM
  2. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  3. Replies: 3
    Last Post: 05-01-2008, 08:30 AM
  4. Error: cannot find symbol
    By silvia in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:39 AM
  5. Error: cannot find symbol
    By cachi in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 08:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •