Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JInternalFrame DISPOSE_ON_CLOSE

807591Jan 20 2006 — edited Apr 15 2008
Hi All

I've got a JInternalFrame (intFrame) with this:-
intFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
I've added a: - intFrame.addInternalFrameListener(this);

Within 'this' I've got: -
public void internalFrameClosing(InternalFrameEvent e) {
        	int i = JOptionPane.showInternalConfirmDialog(intFrame,
"Do you really wish to Close?", 
"Message", 
JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE);
		
//The user must decide weather or not to dispose the JInternalFrame
if( i == JOptionPane.NO_OPTION )
         listenedToWindow.show();   //An effort to prevent it from closing
    }
This does not work. I cannot prevent the JInternalFrame from closing.
I tried overwriting the dispose() method but an exception is thrown saying that intFrame is an invalid parent for JOptionPane.showInternalConfirmDialog(....)
Therefore I conclude that setting the default close operation to dispose does not simply cause a call to method dispose() when the close icon is pressed on the JInternalFrame as I expected.

My Question is this. How can I prevent the JInternalFrame from closing. I wish it to dispose not hide when the user decides to actually close it.

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 13 2008
Added on Jan 20 2006
6 comments
583 views