Netbeans and inner classes/variable access
Not sure if this is the right place to post but it seems most relevant. So basically i create a java form in netbeans. I create a couple of textfields, lets say 'textField1' and 'textField2'. I then create another java class called 'test'(seperate file), im assuming they're inner classes? I just right click on the package and create new class. Anyway, the class 'test' can't access/read 'textField1' and 'textField2', why is that? If 'test' is an inner class, shouldnt it have access to all of the variables and declarations within that were made in the form such as the 2x textfields? In textpad if i create a class within a class in the one file, anything declared in the outside class can be accessed from the inner class. I'm not sure whats wrong? Only just changed to netbeans any help would be appreciated =]
Re: Netbeans and inner classes/variable access
Why do you assume that it's an inner class?
Re: Netbeans and inner classes/variable access
Quote:
Originally Posted by
KevinWorkman
Why do you assume that it's an inner class?
I was told that the inner classes are kept in seperate files? I guess it's not? any idea on how to create an inner class in netbeans?
edit: Ok, so you can just create an inner class inside the main class in the same file, but is there a way to put innerclasses in a seperate file? so it isnt so messy?
Re: Netbeans and inner classes/variable access
Java classes are called "inner classes" because they are truly inside the definition of a Java class. I don't know of a way to get around this (Java doesn't allow you to put the definition of a class into multiple files).
What you could do is create classes in the same package which have default permissions. This allows all the other classes in that package to have access to that class, but no other classes can access that class.