Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Frame.dispose() - does this get rid of the frame in memory too?

 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I have an application where I need a non-modal dialog (the Address Book) to be displayed. Also, not more than one Address Book dialog may be open at a time.

So I made a function that is called when the user clicks on the Address Book button, to check if any Address Book dialog is currently open and if so to bring it to the front.



Then, I need to know when the Address Book dialog is closed by any means (for many reasons.) So I added a window listener to the Address Book.



But what I am finding is that when I close the dialog by any means and in doing so, call the two lines of code in endScreen() is that the dialog still exists. When I do Frame.getFrames() I still land up with an instance of AddressBookDialog that is aruond somewhere.

Can anyone explain why this AddressBook is hanging around and how I can make is hide and die quietly?

Many kind regards,
Rachel
 
Jkarthi keyan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The is code is partial so no one can find where is the error.

regards
Jkarthi
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appologise for posting partial code. I did no think that any other sections of this were relevant in finding the answer. Below I have also posted the code that is called when the Address Book button on the tool bar is pressed.



So to sum up, I have posted the code that gets called to show the new Address Book. This code checks if there is already a frame of the class AddressBookListener existing and if it does exist, that it should show the screen.

I also posted the code that is called when the frame is closed.

After the frame is closed, Frame.getFrames() still contains an instance of AddressBookListener which it should not.

I have posted the portions of the code that I think are relevant and I would be happy to post more if this is still not sufficient.

Many kind regards,
Rachel
[ May 09, 2005: Message edited by: Rachel Swailes ]
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
frame.dispose() places a request to the Garbage Collector to free up the memory. When it gets deallocated is entirely up to the GC.
 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'dispose' is a Window method, see api for details. In general, calling 'dispose' will remove a components peer. The Component will remain in the vm as long as there exists a reference to it. To remove the Component you set all/any references to it to 'null'.
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow! It's only 8:30AM and already I have learned something new today. Thanks guys for your info and Craig, I always see you on the forums and your advice is always great!

Hope you have a super day.
Rachel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic