Results 1 to 18 of 18
Thread: static variable
- 07-02-2008, 09:20 AM #1
Member
- Join Date
- Jul 2008
- Location
- Bangalore, India
- Posts
- 11
- Rep Power
- 0
- 07-02-2008, 09:34 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What you mean refresh? When you load the same class in different classes, on each class have an independent static variables. So the original value stays as it is.
- 07-05-2008, 03:27 PM #3
Maybe "refresh" means to reset the value handled by that static variable.... I guess(base on OP's post)
If that is, then use assignment operator on it....freedom exists in the world of ideas
- 07-07-2008, 05:27 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 07-07-2008, 07:25 AM #5
Member
- Join Date
- Jul 2008
- Location
- Bangalore, India
- Posts
- 11
- Rep Power
- 0
s its like reset
i have created JPanel as static in classA & added that panel to container
in classB am removing that panel
finally am calling classA in button click..
that time i cant get that panel..
for that i want to reset the static variable..
how to do that ??????
- 07-07-2008, 08:09 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Why did you remove that panel?
- 07-07-2008, 08:24 AM #7
Member
- Join Date
- Jul 2008
- Location
- Bangalore, India
- Posts
- 11
- Rep Power
- 0
class2 i given close option to close that panel (panel contents)
i added so many components to that panel..
i cant remove each & every.. so i removed that panel
- 07-07-2008, 08:28 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
This is not a variable define level issue. After removing the panel, on next call there is no such a panel(vanished with all components). So you have to define them all again.
I'm wondering what's the requirement of removing the panel.
- 07-07-2008, 08:39 AM #9
Member
- Join Date
- Jul 2008
- Location
- Bangalore, India
- Posts
- 11
- Rep Power
- 0
am calling again the classA in that time i want to reset the variables..
actually i defined static variable in classA..
- 07-07-2008, 08:42 AM #10
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Just think about that. When you call again what happened to the class A, basically to the content in your GUI.
Can you show your code here.
- 07-07-2008, 09:05 AM #11
Member
- Join Date
- Jul 2008
- Location
- Bangalore, India
- Posts
- 11
- Rep Power
- 0
cant sent code.. its so lengthy.. will explain the process.. give some idea..
am having 3 modules.. created by 3 diff classes.. from login class am calling it by diff user name & pwd.. each module having logout button.. when am calling logout button i want to close that corresponding class & redirect to login page..
again am enter into same module then that static panels r not visible...
what i do
- 07-07-2008, 09:10 AM #12
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
When did you initiated those components? If you use the same object reference it should work. But seems to me, you have deleted it and initiated again. At that time which constructor you are referring? Is that the one, you initiate the panel and all components?
- 07-07-2008, 09:21 AM #13
Member
- Join Date
- Jul 2008
- Location
- Bangalore, India
- Posts
- 11
- Rep Power
- 0
am not using any constructor... is it needed?
- 07-07-2008, 09:28 AM #14
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
With and without we can do it. But I want to know is that how did you initiate all components in your GUI? And also how did you define a object reference to your class from another class?
- 07-07-2008, 09:37 AM #15
Member
- Join Date
- Jul 2008
- Location
- Bangalore, India
- Posts
- 11
- Rep Power
- 0
class A
{
static ELPanel panCode = new ELPanel();
static ELPanel panCode = new ELPanel();
static ELPanel panCode = new ELPanel();
}
- 07-07-2008, 10:26 AM #16
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
why did you define three object reference like this, what is your target?
- 07-07-2008, 11:12 AM #17
Member
- Join Date
- Jul 2008
- Location
- Bangalore, India
- Posts
- 11
- Rep Power
- 0
actually its 3 different names... by mistake i sent it same name.. am using more then one panel in same class..when am clicking diff menu diff panels open.. when clicking close button am showing static page, and closig all panels.. for that am setting setvisible 'false'
when am calling again that time also that setvisible property is false..
- 07-07-2008, 11:22 AM #18
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I'm not clear what you are talking about. If I get correctly you have few number of GUIs. Call them in a menu.
When you close button what you should do is, this is the normal procedure, dispose or exit a specific panel. But still you should have the reference to the panel. When you set visibility to true you can see it and, if you click false you can't see it.
If that is what you didn't see in your application, I'm sure that you have something wrong with the instantiation of the panel.
Similar Threads
-
About static variable
By MarkWilson in forum New To JavaReplies: 5Last Post: 06-27-2008, 01:43 PM -
Non-Static method in static context error
By wizmang in forum New To JavaReplies: 4Last Post: 04-24-2008, 08:51 AM -
Error: Non-static method append(char) cannot be referenced from a static context
By paul in forum Advanced JavaReplies: 1Last Post: 08-07-2007, 05:05 AM -
Error: non-static variable height cannot be referenced from a static context at line
By fernando in forum AWT / SwingReplies: 1Last Post: 08-01-2007, 09:25 PM -
Help with static variable counter
By silvia in forum New To JavaReplies: 1Last Post: 07-19-2007, 07:53 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks