File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Can anyone help? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Can anyone help?" Watch "Can anyone help?" New topic

Can anyone help?

Dave Donohoe
Ranch Hand

Joined: May 16, 2000
Posts: 73
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 ?
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Well, if it were a JFrame you could
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
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
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.
Dave Donohoe
Ranch Hand

Joined: May 16, 2000
Posts: 73
Thanks Chris & Cindy - I think thats exactly what I need !
I agree. Here's the link:
subject: Can anyone help?
It's not a secret anymore!