Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Frustrated lol.

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Frustrated lol.

    heres my program :

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
     
    public class AddSub extends JApplet
    {
    	 int Height = 35;
    	 int Width = 300;
    	private JButton Add;
    	private JButton Sub;
    	private  int num;
    	private JLabel label;
     
    	public void init()
    	{
    		num = 50;
     
    		Add = new JButton("add");
    		Sub = new JButton("subtract");
     
    		Add.addActionListener(new AddButtonListener());
    		Sub.addActionListener(new SubButtonListener());
     
     
    		label = new JLabel("Pushes: "+ Intiger.toString(num));
     
    		Container cp = getContentPane();
    		cp.setBackground(Color.blue);
    		cp.setLayout(new FlowLayout());
     
    		cp.add(add);
    		cp.add(sub);
    		cp.add(label);
     
    		setSize(width,height);
    	}
     
     
    private class AddButtonListener implements ActionListener
    {
    	public void actionPerformed (ActionEvent event)
    	{
    		num++;
    		label.setText("Pushes:" + Intiger.toString(num));
    		repaint();
    	}
    }	
     
     
    private class SubButtonListener implements ActionListener
    {
    	public void actionPerformed (ActionEvent event)
    	{
    		num--;
    		label.setText("Pushes:" + Intiger.toString(num));
    		repaint();
    	}
    }	
     
    }


    and heres the errors....it makes absolutely no sense!! help!!!

    AddSub.java:25: cannot find symbol
    symbol : variable Intiger
    location: class AddSub
    label = new JLabel("Pushes: "+ Intiger.toString(num));
    ^
    AddSub.java:31: cannot find symbol
    symbol : variable add
    location: class AddSub
    cp.add(add);
    ^
    AddSub.java:32: cannot find symbol
    symbol : variable sub
    location: class AddSub
    cp.add(sub);
    ^
    AddSub.java:35: width is not public in java.awt.Component; cannot be accessed from outside package
    setSize(width,height);
    ^
    AddSub.java:35: height is not public in java.awt.Component; cannot be accessed from outside package
    setSize(width,height);
    ^
    AddSub.java:44: cannot find symbol
    symbol : variable Intiger
    location: class AddSub.AddButtonListener
    label.setText("Pushes:" + Intiger.toString(num));
    ^
    AddSub.java:55: cannot find symbol
    symbol : variable Intiger
    location: class AddSub.SubButtonListener
    label.setText("Pushes:" + Intiger.toString(num));
    ^
    7 errors


    EDIT:
    i just got it down to 3 because of some silly variable mis-spellings;
    Last edited by stealthmonkey; December 14th, 2010 at 09:47 PM.


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Frustrated lol.

    It all makes sense. You just made a bunch of spelling and case errors:

    AddSub.java:25: cannot find symbol
    symbol : variable Intiger
    location: class AddSub
    label = new JLabel("Pushes: "+ Intiger.toString(num));
    ^
    It says specifically that it cannot find the symbol: Intiger. Neither can I. I assume you mean Integer.

    AddSub.java:31: cannot find symbol
    symbol : variable add
    location: class AddSub
    cp.add(add);
    ^
    It says it cannot find add. I bet it could find Add.

    AddSub.java:32: cannot find symbol
    symbol : variable sub
    location: class AddSub
    cp.add(sub);
    ^
    Can't find sub; can find Sub.

    AddSub.java:35: width is not public in java.awt.Component; cannot be accessed from outside package
    setSize(width,height);
    ^

    AddSub.java:35: height is not public in java.awt.Component; cannot be accessed from outside package
    setSize(width,height);
    ^
    Another case issue. Your height and width variables are called Height and Width. Since your class extends JApplet and the compiler couldn't find your variables since you used the wrong names, it assumed you were trying to access JApplet's variables named height and width, both of which are not public so you cannot access them directly.

    AddSub.java:44: cannot find symbol
    symbol : variable Intiger
    location: class AddSub.AddButtonListener
    label.setText("Pushes:" + Intiger.toString(num));
    ^
    AddSub.java:55: cannot find symbol
    symbol : variable Intiger
    location: class AddSub.SubButtonListener
    label.setText("Pushes:" + Intiger.toString(num));
    Integer, not Intiger.


    Spelling and Case -- its a bitch.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/