1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Rep Power

    Help me out please!

    Im pretty new to Java and got a question I just cant seem to solve.

    I have a code looking like: (obv alot more but u know what I mean)

    java Code:
    public class project1 extends JFrame implements ActionListener {
    public project1() {
    JLabel jlabel = new JLabel("Dice 1") ;
    public void actionPerformed(ActionEvent e){

    This gives me the error "cannot find symbol".

    I hope u can help me out !
  2. #2
  3. Lord of the Dance
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Oct 2003
    Rep Power
    You have declared jlabel inside the constructor and is therefor only known inside that function.

    Declare it as a class/member varible to fix the error.

    Comments on this post

    • codeJ agrees
    • Arnokeh agrees : Thank you, solved my problem

IMN logo majestic logo threadwatch logo seochat tools logo