Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / September 2004

Tip: Looking for answers? Try searching our database.

All my components need refresh with the new data ???

Thread view: 
Dado - 14 Sep 2004 23:27 GMT
My small application (JTree, JTable & JPanel) draws
data from database and everyting works just fine.
But now I want open button with the new database connected
to my application and all my components and it variables needs new
initalization.
what is the rule to do that? If  I wrote:

MyApp = new MyApp();
MyApp.show();

How to setup all variables in all classes (connection, statement, JTree...)
to null and initialize again?

Could you explain me the regular procedure in open procedure.
1. OpenDialog ...
etc.
etc.
Dado - 17 Sep 2004 13:40 GMT
Let me be a little more specific.
My subquestion is:
When I wrote this:
MyClass  = new MyClass();
does all variables are initialize like I first
create it.

> My small application (JTree, JTable & JPanel) draws
> data from database and everyting works just fine.
[quoted text clipped - 18 lines]
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.725 / Virus Database: 480 - Release Date: 20.7.2004
Andrew Thompson - 17 Sep 2004 14:53 GMT
> When I wrote this:
> MyClass  = new MyClass();
> does all variables are initialize like I first
> create it.

So find out.  Create an object of the class,
use the setXXX method on something that is
initialized, create a second instance and
print them both.

For extra marks, declare an attribute of the
class as 'static' and repeat the experiment,
note and comment on any differences.

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.lensescapes.com/  Images that escape the mundane

Babu Kalakrishnan - 17 Sep 2004 14:53 GMT
[Moving top posted second message down]

>>My small application (JTree, JTable & JPanel) draws
>>data from database and everyting works just fine.
[quoted text clipped - 11 lines]
>
>>to null and initialize again?

> Let me be a little more specific.
> My subquestion is:
> When I wrote this:
> MyClass  = new MyClass();
> does all variables are initialize like I first
> create it.

Speaking from the Java point of view, all *instance* variables of the
class MyClass will get initialized to their default values - but if you
used any static variables and modified their values earlier, they will
not be initialized again - they will retain their values.

But I suspect your question is slightly different and you want to know
if the Frame (or Dialog) that MyClass represents would suddenly change
its appearance to show its new state as soon as you set the variable
"MyApp" to point to a newly created instance ? If so the answer is no.
You would need to dispose off the old Frame and call show() on the new
instance for it to reappear.

BK
Dado - 21 Sep 2004 09:53 GMT
> [Moving top posted second message down]
> >
[quoted text clipped - 34 lines]
>
> BK

OK. I think that dispose() works with JFrame, but how to "dispose" JPanel?

I saw that memory usage grows when
I wrote:
panel.removeAll();
panel = null;
panel = new JPanel();
...
Babu Kalakrishnan - 21 Sep 2004 10:11 GMT
> OK. I think that dispose() works with JFrame, but how to "dispose" JPanel?
>
[quoted text clipped - 4 lines]
> panel = new JPanel();
> ...

A JPanel doesn't need anything special to be done to it for it to be
Garbage collected. Just like any other Java object, you need to only
ensure that no reference to it exists from any other live java object in
your application to ensure that it is /eligible for/ garbage collection.

(In this particular case, you can check if panel.getParent() is null
just before you set it to null. If it is non-null, the parent would be
holding a reference to it in its "children" list)

BK
Dado - 22 Sep 2004 09:31 GMT
> > OK. I think that dispose() works with JFrame, but how to "dispose" JPanel?
> >
[quoted text clipped - 15 lines]
>
> BK

Thank you, some thing are now clear.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.