| 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
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
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.
|
 |
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
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
|
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
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
Maybe this will help. Excuse the bad coding practices.
|
 |
 |
|
|
subject: Stopping an InternalFrame from closing
|
|
|