![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2005
Posts: 8
Rep Power: 0
![]() |
Using variables from other classes/frames
What's the exact way to just use a variable from another frame/class. I have 4 frames and I want my program to set the text on some labels in form 2 which will be done in form 1.
How exactly would I go about doing this? I keep getting this error when I try, "non-static variable fNamelbl cannot be referenced from a static context". Can someone tell me what I'm doing wrong? Last edited by Vengeance; May 2nd, 2005 at 2:44 PM. |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Mar 2005
Location: different places. constantly on the run.
Posts: 57
Rep Power: 4
![]() |
that's when you try to use a normal variable like
int i; instead of static int i; in a method that has been declared static(usually happens in the main method for me). i'm not entirely sure of it, but i think you can get to the variables with Chair chair = new Chair(); chair.legs = 4; else, what you can do, is use a method. chair.setLegs( 4 ); then, in that method you assign the value 4 to the legs variable in that class and the do whatever you want to do with the object. am i on the button?
__________________
There's got to be more to life than being really, really ridiculously good looking |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Apr 2005
Posts: 8
Rep Power: 0
![]() |
Yep, thanks.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|