How to restore the hidden windows
1 posts in topic
Flat View  Flat View

Posted By:   sri_KR
Posted On:   Tuesday, March 27, 2001 09:09 AM

I have an application where I have an edit button, when I click on edit button it opens up a new window.This new window contains a close button when I click on close button ,it should not close that window instead it should hide that window and store it in a hashtable.When I click edit button next time it should search that hashtable and get the hidden window instead of opening the new edit window again

Thanks in advance

Re: How to restore the hidden windows

Posted By:   Christopher_Schultz  
Posted On:   Tuesday, April 3, 2001 07:37 AM

What you want to do is call JFrame.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE). This will prevent your window from being cleaned-up and disposed by Java. After creation, you can store this JFrame in your hashtable.

Next, you'll want to create an implementation of a java.awt.event.WindowListener which watches for windowClosing events. When that event is caught, call JFrame.setVisible(false).

The next time you want to show the window, search your hashtable for the appropriate one. If it's there, call JFrame.setVisible(true) and your window should be back.

Don't forget to re-initialize the fields on the window before you make it visible, or your user will be confused.

About | Sitemap | Contact