This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I know this has been explained at length before but I don't get it ! I have a JFrame, and when it is created and initialised, I set
Then, for the window Closing event, I have a JOptionPane ConfirmDialog box pop up which asks the user if they want to save before closing. Whichever option they choose .... it closes ! It should NEVER close ... any ideas ? Cheers, Kate
HI, You told the Frame to <b>do nothing</b> on closing NOT <b>not to close</b>! As far as I know you cannot stop a top-level container from closing. You could assign an OptionPane to the windowClosing(WindowEvent e) event - which is generated before it dissappears and then allow the user to cancel - though you'd have to capture the close event and consume it or something similar. You can configure a JInternalFrame as not closable. Hope that helps,
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: May 30, 2001
Yes Nathan, You're absolutely right, of course. I suppose I should have tested some code before mouthing off. Well I've learned something new today Terry
Joined: Apr 17, 2001
Hmm, but it didn't work for me !!! I'm developing it in Visual Age, so it takes some chopping about to post code. Maybe I'll have to do that, cos I definitely set the default Close operation to do nothing, and it just goes off and closes all by itself, no matter what I tell it to do...
Make sure that Visual Age isn't inserting any propriatary API calls (i.e. com.ibm.*) if you are generating code, and also see if any other listeners are being added to your frame... even if you set your frame to do nothing on close, if there is a listener, or if the frame uses processWindowEvent(), it will still exit.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com