Hi all, I have a Desktop with a number of JInternal Frames in it. When the user closes a JInternalFrame, I have a Popup asking if the user is sure they want to continue. If the user clicks YES, the window is closed, & if the user clicks NO the window should not be closed. however, to do this I added an InternalFrameListener & used the method 'internalFrameClosing'. the problem is that for this method to be triggered, the app is in the process of actually closing the internal window. How do I stop the window being closed when the user clicks NO ? Is there a different Listener I could use ? Thanks, Dave
Well, if it were a JFrame you could setDefaultCloseOperation(DO_NOTHING_ON_CLOSE) then if the user responds Yes, you could explicitly dispose of the window. However JInternalFrame doesn't have that. The closest that I see is to set the JInternalFrame closable(false). Then if they answer yes, dispose of it. I haven't tried this, so if you give it a try could you tell us how it worked??
"JavaRanch, where the deer and the Certified play" - David O'Meara
JInternalFrame does provide this function public void setDefaultCloseOperation(int operation) Sets the operation which will happen by default when the user initiates a "close" on this window. The possible choices are: DO_NOTHING_ON_CLOSE - do not do anything - require the program to handle the operation in the windowClosing method of a registered InternalFrameListener object. HIDE_ON_CLOSE - automatically hide the window after invoking any registered InternalFrameListener objects DISPOSE_ON_CLOSE - automatically hide and dispose the window after invoking any registered InternalFrameListener objects The value is set to DISPOSE_ON_CLOSE by default. From there you can follow Cindy's lead and explicitly close the window if "Yes" is clicked.
Joined: May 16, 2000
Thanks Chris & Cindy - I think thats exactly what I need ! D