| Author |
Netbeans headaches
|
Kaleey James
Greenhorn
Joined: Aug 15, 2006
Posts: 2
|
|
Hey folks, I have this source file here. When I try to compile it in Netbeans 5.5 (Mac), I get errors in my inner class methods which seem to indicate that the inner classes can't access the variables, etc of the outer class. Can someone help me determine what I'm doing wrong? To summarize, it should create a window with a panel - the panel has a little icon on it that should move when I press the arrow keys on my keyboard. I'm fine with debugging once the code works, but this is ht I get when I try to compile the beast:
Compiling 1 source file to /Users/Bex/javawork/practiceapp1/build/classes /Users/Bex/javawork/practiceapp1/src/practiceapp1/Main.java:59: cannot find symbol symbol : variable x location: class practiceapp1.Main.MacListener x--; /Users/Bex/javawork/practiceapp1/src/practiceapp1/Main.java:62: cannot find symbol symbol : variable y location: class practiceapp1.Main.MacListener y--;
etc, etc. Any help [ March 28, 2007: Message edited by: Kaleey James ]
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
This has nothing to do with Netbeans. This is basic programming 101. Variable Scope. You decared your x and y variables in the main method which makes them "local variables". The only place those variables have scope is within the main method. Make them "member variables" so they are available at the class level. Also, if you are going to declare variables with an initial value, you might as well do it on one line so... int x = 20; rather than int x; x = 20; And I moving this to the Java In General (Beginner) forum.
|
 |
Kaleey James
Greenhorn
Joined: Aug 15, 2006
Posts: 2
|
|
bleep bleep bleep!!! I should have seen that - sorry, been a bit rusty. I thought I tried that already. If it doesn't fix my problem (or I get a new one), I'll post with updates. Thanks! ~KJ
|
 |
 |
|
|
subject: Netbeans headaches
|
|
|