File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Stopping an InternalFrame from closing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Stopping an InternalFrame from closing" Watch "Stopping an InternalFrame from closing" New topic
Author

Stopping an InternalFrame from closing

Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
I have an internalFrameListener, and on the "internalFrameClosing" method/event, I want to popup a save window with (y/n/cancel), easy enough. My problem is if they hit cancel I want the window to not close. Is there a way to stop it from closing?

-Tad
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

You need to do the following, depending on how you are creating your internal frame you'll need to change whatever necessary...



Then in your method you described, if no or cancel is selected, just don't do anything. If you want the frame to close you'll have to do that manually using the dispose() method.


GenRocket - A Test Data Generation Platform
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
Ok... but how do I listen for the close operation of the internal frame then? it seems to just disable the [x] button on the internal frame.

-Tad
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
nm... guess I need to register the internalframe with the listener doh.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

When you tell it DO_NOTHING_ON_CLOSE a close event is still fired. The frame just won't do anything because of it. So in your internalFrameClosing method you would need to either call the dispose() method or do nothing.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Maybe this will help. Excuse the bad coding practices.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stopping an InternalFrame from closing
 
Similar Threads
Cancelling close in windowClosing
A question about closing a shell in SWT
ShutDownHandling for Swing Application
reloading page without retry button popup
How to stop browser pange closing without showing confirm dialog box