Prompt user to save change before abnormally closing the application

Hi,
I've some trouble prompting user to save change before abnormally closing the application (logging off, shutdownding machine...). I tried to use Runtime.getRuntime().addShutdownHook() and it doesn't seem to work. Here's part of my code. Help please!!!
program print out "1" and stays in a "dead-lock" mode...
private void shutdown() {
boolean saveConfig = true;
if (saveConfig) {
System.out.println("1 ");
int answer = JOptionPane.showConfirmDialog(null,
"Configuration has been changed. Do you want to save
configuration before exit?",
"Save Config"
JOptionPane.
YES_NO_CANCEL_OPTION);
JOptionPane.showMessageDialog(this, "Can't connect to unit. Error in Heal unit!", "Error", JOptionPane.INFORMATION_MESSAGE);
System.out.println("2 ");
if (answer == 0) {
savefileButton_actionPerformed();
jMenuFileExit_actionPerformed();
else if (answer == 1) {
jMenuFileExit_actionPerformed();
else {
return;
else {
int answer = JOptionPane.showConfirmDialog(itself,
"Are you sure you want to exit? ",
"Exit",
JOptionPane.YES_NO_OPTION);
if (answer == 0) {
jMenuFileExit_actionPerformed();
else {
return;
private class MyShutdownHook extends Thread {
public void run() {
shutdown();
// add shutdown hook
MyShutdownHook shutdownHook = new MyShutdownHook();
Runtime.getRuntime().addShutdownHook(shutdownHook);

doesn't much matter. shutdown hooks are not guaranteed to run or be able to finish.

Similar Messages

  • Prompting user to save changes before leaving jsp

    Folks,
    I want to be able to prompt the user to save changes on the page that he's on, before he navigates to a different one. one idea i explored is using the body onUnload event. the problem is that my page is split into multiple jsps with tiles, and the body tag is in a common tile that i can't really access.
    Any other ideas on how to do this?
    Thanks,
    Nilesh

    nthali wrote:
    well, onbeforeunload seems to be an IE specific event. we have some customers using firefox etc.It works in at least IE 5.0, FF 1.5 and Safari 1.3. Only not in Opera yet, because it very strictly follows the w3 standards. It doesn't support the onunload either though, which was also invented by Microsoft and adopted by FF and Safari, only a bit earlier than the onbeforeunload.
    And as I already said, the onunload is already too late. The browser will (already) be closed regardless of the (outcome of the) warning message.

  • I have forgotten my security question answers, i have tried to reset them but it keeps saying i need to save changes before i leave the page, i try to but it does nothing. help?

    i have forgotten my security question answers, i have tried to reset them but it keeps saying i need to save changes before i leave the page, i try to but it does nothing. help?

    Reset Security Questions
    Frequently asked questions about Apple ID
    Manage My Apple ID
    Or you can email iTunes Support at iTunes Store Support.
    If all else fails:
    Go to: Apple Express Lane;
    Under Product Categories choose iTunes;
    Then choose iTunes Store;
    Then choose Account Management;
    Press Continue;
    Now choose iTunes Store Security and answer the bullet questions, then click Continue;
    Sign in with your Apple ID and press Continue;
    Under Contact Options fill out the information and advise iTunes that you would like your security/challenge questions reset;
    Click Send.
    You should get a response within 24 hours by email.
    Presently there appears to be problems on Apple's end, so it may be quite some time before they respond.
    Another user had success doing the following:
    I got some help from an apple assistant on the phone. It is kind of round about way to get in.
    Here is what he said to do and it is working for me...
    on the device that is asking you for the security questions go to "settings", > "store" > tap the Apple ID and choose view"Apple ID" and sign in.
    Tap on payment information and add a credit/debit card of your preference then select "done", in the upper right corner
    sign out and back into iTunes on the device by going to "settings"> "store" > tap the Apple ID and choose "sign-out" > Tap "sign -in" > "use existing Apple ID" and you should be asked to verify your security code for the credit /debit card and NOT the security questions.
    At this time you can remove the card by going back in to edit the payment info and selecting "none" as the card type then saving the changes by selecting "done". You should now be able to use your iTunes store credit without answering the security questions.
    It's working for me ...I just have to put in my 3 digit security pin from the credit card I am using.
    Good Luck friends!

  • ARD 3 not prompting user to save changes on restart

    Hello! I have ARD 3 and when I send out a restart command and select the radio option "Users can save changes or cancel restart" it acts as if I didn't select this, and instead selected "Users lose unsaved changes".
    This has never worked for me. If working properly, it SHOULD actually show up on the affected computer a dialog popup of some sort providing the user just those option: to save changes or cancel restart.
    What is wrong/going on, and how do I fix it?
    Thanks ahead of time,
    Sam M.

    nthali wrote:
    well, onbeforeunload seems to be an IE specific event. we have some customers using firefox etc.It works in at least IE 5.0, FF 1.5 and Safari 1.3. Only not in Opera yet, because it very strictly follows the w3 standards. It doesn't support the onunload either though, which was also invented by Microsoft and adopted by FF and Safari, only a bit earlier than the onbeforeunload.
    And as I already said, the onunload is already too late. The browser will (already) be closed regardless of the (outcome of the) warning message.

  • ARD 3 not prompting user to save changes even when told to

    Hello! I have ARD 3 and when I send out a restart command and select the radio option "Users can save changes or cancel restart" it acts as if I didn't select this, and instead selected "Users lose unsaved changes".
    This has never worked for me. If working properly, it SHOULD actually show up on the affected computer a dialog popup of some sort providing the user just those option: to save changes or cancel restart.
    What is wrong/going on, and how do I fix it?
    Thanks ahead of time,
    Sam Marcus

    Slava Natapov wrote:
    Samita wrote:
    Whenever a user changes some items in Block_1 and presses save button, the values from non_db items get copied to the db_items (based on view) and commit_form is called. Try to copy values to the db_items not in save button, but in WHEN-VALIDATE_ITEM of non_db items.- I created the non-db items becoz, it was asking me 'Do you want to save changes', even when I only queried data from the view (becoz i was doing some computations while displaying the items. and the form assumed that the DB items were begin changed ). Inorder to get rid of that problem, i used mirror_items (non-db) for all the db items.
    So under this scenario, when i copy values to the db_items in WHEN-VALIDATE_ITEM trigger of non_db items, the form considers the db_items are changed and asks 'Do you want to save changes' even when the user has not made any changes and only queried data.
    Edited by: Samita on Dec 9, 2009 10:12 AM

  • How to prompt users to save changes?

    Hi,
    I am using WAD to develop planning layouts for BIIP.
    I am curious as how to prompt the user to save the changes thay made to the data on the layout if they decide to navigate away from the page.
    Any suggestions?
    thank you

    Hi AG
    Did you find the place choosing the options? I didn't remenber them all, you can try to search these options.If you want to change the default value of this option, you can go to System Administration --> System Configuration --> Service Configuration --> Applications --> com.sap.portal.epcf.loader --> services --> epcfloader. Set the value of Workprotect.mode.default, which default is 1, and other three options are related to 2, 3, 4.
    Best regards.

  • How to prompt users to save changes to layouts

    Hi,
    I am using WAD to develop planning layouts for BIIP.
    I am curious as how to prompt the user to save the changes thay made to the data on the layout if they decide to navigate away from the page.
    Any suggestions?
    thank you
    Message was edited by:
            AG

    They can use Acrobat to save the form.
    If they only have Adobe Reader, they need to Reader extend the form, to enable Adobe Reader to save the form with data.
    Jasmin

  • Firefox won't save changes I make to the applications actions panel. Specifically, changing pdf files to open in Firefox

    If I change the option to "Use Adobe acrobat in Firefox", the next time I open Firefox, it will have reverted its setting back to "Use adobe Acrobat 7.0"

    Using "System Restore" can cause your Firefox installation to get corrupted because not all files are restored (only files in a white-list), so be cautious with using System Restore.<br />
    You need to (re)install software that was affected.<br />
    Remove the Firefox program folder (C:\Program Files\Mozilla Firefox\) before reinstalling a freshly downloaded Firefox copy to do a clean install.
    You can find the latest Firefox release in all languages and for all Operating Systems here:
    *Firefox 11.0.x: http://www.mozilla.org/en-US/firefox/all.html
    Remove all rules for Firefox and the plugin-container from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
    See:
    *https://support.mozilla.org/kb/Server+not+found
    *https://support.mozilla.org/kb/Firewalls

  • Adobe Reader X prompting me to save changes every time I close a document! Please help

    I open the PDFs and when I close it, it asks me "Do you want to save changes before closing", when there are no changes made!
    This is such an inconvenience, please help to solve the issue. I tried to go to Edit -> Preferences -> Documents -> and unchecked Save settings options, but it didnt work

    Thanks Pat. It so happens that I myself am the author of these PDFs. Is there something I need to change (settings etc) and rebuild these files, so the issue doesnt recur? BTW, I am using Adobe FrameMaker 11 to create the docs.
    If there is a link which addresses this issue, please point me to that.
    Thanks in advance....

  • What is the user exit to change segment version at the run time of an IDOC

    Dear Experts
    Please can some one help on this ...
    Which is the user exit to change segment version at the run time of an outbound IDOC.
    For example
    Suppose we have a IDOC segment with two version 620 and 46C.
    By default the IDOC pick the 620. But Our requirement is to use 46C.
    What user exit we can use for outbound IDOC to change the version used at run time for a segment.
    Appreciate your response.
    Thanks

    Hi,
    ALE00001      EXIT_SAPLBD11_001         
    User exit for the IDOC version changer
    Regards,
    Ravi

  • USER EXIT FOR CHANGING POSTING DATE IN THE MATERIAL DOCUMENT

    Hi,
    Pls advise any USER EXIT FOR CHANGING POSTING DATE IN THE MATERIAL DOCUMENT.
    Regards,

    Hi,
    There is another user exit for updating material document data Upon posting  is MB_CF001
    I hope this will fullfill you.
    Prem

  • The PSE 10 process doesn't stop after closing the application. Why??

    On Windows 7, the PSE 10 process doesn't stop when closing the  application, therefore the PSE 10 app. will not restart once it is closed. The user must stop the process from task manager or reboot before PSE 10 can be restarted on a Windows 7 machine. The forum suggestion to double-click the exe (instead of the shortcut) as a solution, obviously isn't a solution and can't work. There are no updates to PSE 10 and the only access to any support is through this forum. There have been complaints about this on blogs all over the Internet. Why can't Adobe come up with a fix/update or if they have where is it posted?

    First of all, there is no difference between the files on the disk and those downloaded as the trial. The only difference is that one comes with a serial number and the other does not. You can put your serial number into the trial version and it will then be activated. The only way the disk would behave differently is if there is some physical flaw (scratches, warping, etc). Usually such damage will cause the installation to fail, it's pretty difficult for such damage to modify the files in such a way that they still install but behave differently.
    If you are dropping a file on the shortcut and the Photoshop Elements Editor is opening but the file is not, there could be a few different things going on there. Check your shortcut properties first: does it go to PhotoshopElementsEditor.exe or Photoshop Elements 10.0.exe? If the former, then there are probably some missing support files. If the latter, this is the Welcome Screen, which has likely been configured to launch the Editor automatically. However, you would be sending the file to the Welcome Screen, which doesn't do anything with the file. It is not capable of passing the file off to the Editor, only capable of launching it.
    Also, double-clicking a shortcut is generally the exact same thing as double-clicking the file the shortcut points to, but you can add modifiers to shortcuts to make them behave differently.

  • Many times it happens that even I had closed the application window i had to manually  quit the application by going in 'forced quit'..any solution .. :(

     many times it happnes that even I had closed the application window  it keep running  on backend and I have to manualy close it again by going in  'forced quit'.. any solution.... 

    Closing the window doesn't quit the application on Mac like it does in Windows. You have to select Quit (Program Name) from the top menu or use the keyboard shortcut Command + Q

  • Why FF usaes 25% of CPU, even after closing the application..?

    After opening two or more browser, automatically FF stars using 24/25% of CPU.
    Even one tab having Youtube running.
    As well as using huge amount of memory, and this gradually increases.
    Closing the application doesn't solves the problem.
    After that the application doesn't opens. A window appears and shows.. Firefox already running and is not responding.
    Going to Task manager and kill the process solves the problem.
    And it's happening every time.
    In cyclic order need to follow the annoying process.
    .....Tried the processes but NO result found.....
    Re-installation of FF didn't worked.
    Re-installed Flash player.
    No malware found by Malwarebytes.
    Even tried running FF in safe mode. (disabling all plugin and extensions)
    And the result is.... NO progress. CPU 25% usage and had to kill the task.
    Please some one help.
    (OS: windows 7 professional)

    Your computer isn't getting slower, it's other things demanding faster.  If you are installing all the possible updates to software those will be designed for newer computers.  Once you start browsing you're browsing a web designed by people who because they spend all their time designing pages they themselves have powerful machines with fast connections because it is their job.  It's like if all city streets were designed by racecar drivers.  A 2008 computer is already considered vintage by Apple and close to no longer being supported in any manner.  Vintage and obsolete products - http://support.apple.com/kb/HT1752  I have an even older computer than you and it is annoying but that's the way things are.
    Frankly 4-6 icon bounces doesn't sound long to me.  Don't forget that for applications such as iTunes how long it takes to open will also depend upon the size of the library.
    I don't think CPUs wear down.  Conceivably some slow-down could be the result of excessive bad sectors on a hard drive but you say you replaced that (and I would expect it to have shown more serious symptoms were that happening).
    You can use Activity monitor to check your RAM usage.  Newer applications and newer OS versions will require much more RAM than posted "minimum"  If a computer doesn't have enough RAM it starts using the hard drive which is slower than chips.

  • HT4414 I get a message "In order to continue installation, please close the following application.  I closed the application, but the message does not close and the installation is "frozen" ... how do I reset?

    I get a message "In order to continue installation, please close the following application.  I closed the application, but the message does not close and the installation is "frozen" ... how do I reset?

    Try posting in the Mountain Lion forum. Here is the link below. This forum is for old software circa 2003.
    https://discussions.apple.com/community/mac_os/os_x_mountain_lion

Maybe you are looking for