• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stopping an InternalFrame from closing

 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nm... guess I need to register the internalframe with the listener doh.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe this will help. Excuse the bad coding practices.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic