Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Detecting when a JFrame visibility is set to false.

843805Feb 28 2007 — edited Mar 1 2007
Hi to all

I currently have the situation where I have a JFrame with a table containing data loaded from a database. Double clicking on a row in the table brings up another JFrame allowing you to edit the data for that row. When you've finished editing the data clicking on okay uploads teh new data to the database and hides the JFrame using
editFrame.setVisible(false)
What I would like to happen is that when the editing frame is hidden the JFrame containing the table should reload the data from the database to reflect the changes made.

To acheive this I've tried both of the following: adding an implementation of WindowListener to the table JFrame and adding a window listener to the editing JFrame so that in theory when the editing JFrame closes it fires a WindowEvent picked up by
public void windowClosing(WindowEvent e) 
which calls the relevant methods to reload the data. But as far as I can tell, setting the JFrame visibility to false does not generate a windows event.

My other alternative was to implement a WindowFocusListener in the table JFrame so that when the editing JFrame closes the table JFrame requests focus, triggering an event picked up by
public void windowGainedFocus(WindowEvent e)
which again would call the relevant methods, but this also didnt work.

I've looked and I can't see any methods to implicitly close a JFrame, so at the moment I'm rather stuck. If anyone's got any suggestions please share :-)

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 29 2007
Added on Feb 28 2007
9 comments
539 views