Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can anyone help?

 
Dave Donohoe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Chris & Cindy - I think thats exactly what I need !
D
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic