Navigation Screens with Swing

Hi,

I am new to Swings.

I have a work flow system which has sequence of screens developed using swings. For navigation from one screen to another code that is used is,

On button click event,

new ScreenObject().setVisible(true);

this.setVisible(false);

But in this method, old object remains in memory through out the application. If this is the right approach ?

If it is, how do i destroy old objects from the last screen of the application if user closes last screen. Last screen has only

this.dispose();

which will dispose current screen objects.

Please guide.

Thanks and Regards

Nagarajan

[769 byte] By [Nagarajan82a] at [2007-10-3 9:50:10]
# 1
You code is mimicking the use of CardLayout which would probably be much better suited to your task.I see no problem in keeping all your work flow screens in memory unless of course there are 100s in which case you would have a design fault.
sabre150a at 2007-7-15 5:07:20 > top of Java-index,Desktop,Core GUI APIs...
# 2

Hey,

if I understand you correctly you need just a reference in the new screen from the old one. On this reference you should invoke:

oldScreen.dispose();

to kill it from the heap.

oldScreen.setVisible(false);

lets the screen disappear from the screen (monitor) and it doesn't remove it from the memory...

btw. are you sure that

new ScreenObject().setVisible(true);

works?

I hope that helped a bit.

SpecialAgenta at 2007-7-15 5:07:20 > top of Java-index,Desktop,Core GUI APIs...