Save on Exit

Hi,
I wanted to prompt for saving a file when the JFrame is getting closed. How can I implement this? Any suggessions would be helpful.
Thanks

First of all, you would need to stop the frame's defaultCloseOperation and substitute it with your own behavior. Here is a snippet from the main method of a program I have done this with:
   public static void main(String[ ] args)
      final MyAppFrame fr = new MyAppFrame();
      fr.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
      fr.addWindowListener(new WindowAdapter()
         { public void windowClosing(WindowEvent e)
            { fr.exitApp(); } });
   }When the Frame's close button is clicked, the exitApp() method is called. Here you can create a JOptionPane to ask the user if they want to save the file.
   public exitApp()
      JOptionPane option = new JOptionPane();
      int opt = option.NO_OPTION;
      if (fileHasChanged())   // ask if it should be saved
         Toolkit.getDefaultToolkit().beep();
         opt = option.showConfirmDialog(owner, "Save changes to current document?",
               "Exit", option.YES_NO_CANCEL_OPTION, option.WARNING_MESSAGE);
      if (opt == option.YES_OPTION) { saveFile();  System.exit(0); }   // save the file and exit
      else if (opt == option.NO_OPTION) { System.exit(0); }   // exit the application without saving
      else return;   // just go back to the program
}-Chris

Similar Messages

  • What happened to the Bookmark all Tabs/Save and Exit/Open previous session feature in 4.0? If this has been taken out then 4.0 is of no use to me. I'll have to go back to 3.6

    In 3.6 when ever I closed the browser with multi tabs open it would give me the option to Save and Exit. Then when I reopened the browser it would give me the option to open the previous session. I could also bookmark all open tabs. All of these features appear to no longer be present in 4.0. If this is the case I will be forced to uninstall and reinstall 3.6.

    Bookmark All Tabs - you can get it when you right-click on a tab, or use keyboard shortcut Control+Shift+D.
    Firefox now always stores the old session, and you can access it by going to the History menu and selecting "Restore Previous Session"
    If you want Firefox to display the message to save the session, it can be turned back on by changing some preferences.
    # Type '''about:config''' into the location bar and press enter
    # Accept the warning message that appears, you will be taken to a list of preferences
    # Locate the preference '''browser.tabs.warnOnClose''', if its value is set to '''false''', double-click on it to change its value to '''true'''
    # Repeat this for these 3 preferences '''browser.warnOnQuit''', '''browser.warnOnRestart''' and '''browser.showQuitWarning'''
    If you always open the last set of tabs, an alternative approach is this:
    # Click the orange Firefox button, then select options to open the options window
    # Go to the General panel
    # Change the setting "When Firefox starts" to "Show my windows and tabs from last time"

  • How to  read header texts in the on save user exit of VA01

    Hi Experts,
    I have a requirement to read the header texts in the on save user exit.
    I have to check whether departmental code in header text is not initial or not.
    Can any one please pour in some points of how it can be done......
    Thanks in Advance.
    Prem

    Hi
    U can use fm READ_TEXT:
    DATA: THEAD LIKE THEAD,
          TLINES LIKE STANDARD TABLE OF TLINE WITH HEADER LINE.
    THEAD-TDID     = <text id>.
    THEAD-TDSPRAD  = <language>.
    THEAD-TDOBJECT = 'VBBK'.
    THEAD-TDNAME   = VBAK-VBELN.
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
        ID                            = THEAD-TDID
        LANGUAGE                      = THEAD-TDSPRAD
        NAME                          = THEAD-TDNAME
        OBJECT                        = THEAD-TDOBJECT
      TABLES
        LINES                         = TLINES
    EXCEPTIONS
       ID                            = 1
       LANGUAGE                      = 2
       NAME                          = 3
       NOT_FOUND                     = 4
       OBJECT                        = 5
       REFERENCE_CHECK               = 6
       WRONG_ACCESS_TO_ARCHIVE       = 7
       OTHERS                        = 8
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    U can use it in all situations ( inserting and updating) because that fm returns the buffered text.
    Max

  • Occasionaly my FCP does not save on exit, is it just me?

    On some occasions varies, fcp does not save on exit, it just goes. Other times its polite and says , wanna save ya changes mate?
    Yes there has been changes made cos on re open the stuff I done has gone!
    I do try and save manually as often as I can learning this, and I have auto save on 5 mins.
    I just think its a bit poor on continunity, either dont save on exit or save, rather than giving me the run around.
    Does this happen with you guys or just me? please add your comments
    Daz

    sounds like FCP is crashing on exit
    I would perform all the usual maintenance proceudres:
    trash FCP preferences
    Disc Warrior
    repair permissions

  • My iPod now loses my Klondike scores/settings after I "save and exit".  How can I fix this?

    After my last iTunes sync, my iPod loses my Klondike scores/settings after I "save and exit".  How can I fix this?

    I'd try a hard reset, you have nothing to lose.  If that doesn't help and you can shut off the iPod (i.e. the white screen becomes black) you can try to recover it: http://support.apple.com/kb/HT1808
    If that still does not fix the problem and it was Apple that replaced the iPod, return it to them, you have a 90 Day Warranty.  If you replaced the screen yourself,  I have no idea if you did something wrong in the repair or if the replacement screen was defective.  That is the main risk of a self repair.  I doubt whether Apple will do an out-of-warranty repair on an iPod that has been opened, but you can try.

  • Built-in SSH Terminal question on how to save and exit

    Howdy, Heres my question and problem.
    I haven't been able to figure out how to save and exit the editor for the SSH terminal that the mac has. I've read that to save you press control -O hit return and to exit hit control -X but that doesn't seem to be working.
    I'm trying to install imagemagick onto my web server and I get stuck at that point of saving and then exiting.
    can anyone tell me how to save and exit the editor?
    I hold down control press -O i let go of the buttons then i press control -X and it stays at the same editor like nothing happened. I try quitting the terminal and reloading it all but that just causes me to restart and nothing saved. and I actually hit the "-" key should i do that or no?
    heres the instructions I'm following for the imagemagick install.
    (For this next part, if you don't have "pico", you can use "vi" instead)
    $ cd libtiff-lzw-compression-kit
    $ pico Makefile
    change
    TIFFSRCDIR = /tmp/libtiff
    to
    TIFFSRCDIR = ../tiff-v3.5.5
    Then save and exit the Editor $ make install
    $ cd ..
    $ cd tiff-v3.5.5
    $ ./configure
    thanks for any help
    -Ahufs

    ctrl+x (thats both keys at the same time) will invoke the exit of the program. at wich point if youve made changes to the file it will ask you if you want to save the data or not. If yes you need to type yes or y and hit enter... if no then no or n. Then it will ask you what you want the file name to be with the default being whatever the file was that you opend to buffer to work on so in most cases you hit enter again.
    hitting ctrl+o (thats both at the same time again) should write the file out and close the application without prompting i think (i dunno for sure... i always use ctrl+x myself).
    At least thats on the OS X version of pico... your server is probably linux so it may differ although i wouldnt expect it to. my pico bindings have always been the same from Debian to CentOS to Darwin.
    Also i msut ask... why cant you pass the TIFFSRCDIR as an option to ./configure like normal instead of manually editing the make file?

  • Query on Billig Save User-exit

    Hello Folks,
    This question is related to SD (Billing Area).
    We have a requirment, In the Billing Save User-exit 'RV60AFZZ', we need check for the VAT Reg No of the Sales Org in a Z-table, if its not configured in it then we need to stop the Billing creation.
    i.e, when sy-subrc ne 0, stop the Billing generation.
    We tried with the commands 'check' and 'Exit', these did not work. The control exits from RV60AFZZ but the billing is still created. Then we tried command 'STOP'. This works good in online mode (VF01), however in batch mode there is an issue. The billing for the particular document (when sy-subrc ne 0) is stopped, however the job skips all the docs for billing generation. But the Job does not abort.
    I know that the copy control routines are the perfect choices for implementing this kind of logic. However due to the other requirements we had to put the logic in the Billing save User-exit,
    Can someone help me here.
    I need to stop the billing generation( in batch mode )for a particular doc based a check (if sy-subrc ne 0) and the batch job should invoice the rest of the docs which it picks from the Billing due list.
    Regards,
    Mohan Krishna

    Hi
    U can use fm READ_TEXT:
    DATA: THEAD LIKE THEAD,
          TLINES LIKE STANDARD TABLE OF TLINE WITH HEADER LINE.
    THEAD-TDID     = <text id>.
    THEAD-TDSPRAD  = <language>.
    THEAD-TDOBJECT = 'VBBK'.
    THEAD-TDNAME   = VBAK-VBELN.
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
        ID                            = THEAD-TDID
        LANGUAGE                      = THEAD-TDSPRAD
        NAME                          = THEAD-TDNAME
        OBJECT                        = THEAD-TDOBJECT
      TABLES
        LINES                         = TLINES
    EXCEPTIONS
       ID                            = 1
       LANGUAGE                      = 2
       NAME                          = 3
       NOT_FOUND                     = 4
       OBJECT                        = 5
       REFERENCE_CHECK               = 6
       WRONG_ACCESS_TO_ARCHIVE       = 7
       OTHERS                        = 8
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    U can use it in all situations ( inserting and updating) because that fm returns the buffered text.
    Max

  • After downloading ver 4.0, i do not have the option of "exiting" or "sava and exit." Only "exit"

    My most favorite benefit of Firefox is that I can "save and exit" I recently downloaded the newest version , 4.0. Since then when I goto "file>exit> click to execute, I am not given the option of "save and exit" How do I get this feature back?

    Firefox now always stores the old session, and you can access it by going to the History menu and selecting "Restore Previous Session"
    If you want Firefox to display the message to save the session, it can be turned back on by changing some preferences.
    # Type '''about:config''' into the location bar and press enter
    # Accept the warning message that appears, you will be taken to a list of preferences
    # Locate the preference '''browser.tabs.warnOnClose''', if its value is set to '''false''', double-click on it to change its value to '''true'''
    # Repeat this for these 3 preferences '''browser.warnOnQuit''', '''browser.warnOnRestart''' and '''browser.showQuitWarning'''
    If you always open the last set of tabs, an alternative approach is this:
    # Click the orange Firefox button, then select options to open the options window
    # Go to the General panel
    # Change the setting "When Firefox starts" to "Show my windows and tabs from last time"

  • Availability check run requirement in the Sales order Save user Exit.

    Hi Gurus,
    As per the requirment we are using a user exit SAVE SALE ORDER PREPARE for BOM purpose to reconfirm the confirmation qty.
    Now we need to add one more logic in the same user exit, which will run the availabilty check run for each of the line items of the BOM and consider latest confirmation qty from it. So my concern is it possible that we can call the availabilty check run event with in the user exit SAVE SALE ORDER PREPARE or this not advisable?
    Please let me know..
      Regards,
      Babs

    HI Venkat,
    Thanks for your reply.Yes you are right availability check runs automatically at sub item level.
    But please note the customer requirment iteself is is little different from std BOM configuration.
    Currently the availabilty check is activated both at header and sub item level. They are maintaining the stock for header and sub item level.Also the these sub items are some time being sold as invidual materials. hence there exist a mismatch in the stock value between header and sub items.
    when a sales order is created both header and sub items will have confirmation with different value between each and the same mismatched values are being passed in to delivery. But the deliveries can not be processed for PGI because of the mismatched confirmation qty between header and item level.
    I guess now you the rrequirment.
    So we are using the SAVE SALE ORDER exit which will re check the confirmed qty between header and item and takes lowest confirmed qty and change the confirmed quantities from all the line items to lowest one, so that confirmation qty among all the line items are same. This is the first logic we are planning.
    Further there is one more additional process BOP need to be run for this header and sub items, which will change the confirmed qty based on the latest stock for individual line item. even in this case also the user exit SAVE Sale order is being called but we need to run the availability check run additionally because of which our requirment will be taken care.
    Regards,
    Babs

  • Save upon exit

    I get a dialog each time I exit. It says C:\document and setting\osusername\.sqldeveloper\tmp\sqldev58722.sql has been modified. Save changes?
    version 1.0.0.13.43 build-main-13.43
    proper to say yes or no?

    In EA4, we began to write the contents of your SQL Worksheet to a temporary file so that if you crashed you would not lose any statements you were working on. You can just say No. When you are getting this - do you have a Worksheet open?
    -- Sharon

  • 4 won't save and exit..lose all opentabs..no help services or feedback options work. doing this on an un-upgraded computer!! right now 4 sucks!!

    Everything looks different and many old features appear to be gone. All open tabs close automatically on exit without save option and there is no ability to go back to an open page within the same tab without backing through each page(no pull down bar). 4 is not friendly or efficient at all compared to 3.16.6. When you exit it closes all tabs that are open with no option to save and I can not get any of the help or feedback functions in the help menu to open.

    If you want Firefox to warn you when you exit,one change in Firefox 4 is to by default stop Firefox displaying the warning message, but it can be turned back on by changing some preferences.
    # Type '''about:config''' into the location bar and press enter
    # Accept the warning message that appears, you will be taken to a list of preferences
    # Locate the preference '''browser.tabs.warnOnClose''', if its value is set to '''false''', double-click on it to change its value to '''true'''
    # Repeat this for these 3 preferences '''browser.warnOnQuit''', '''browser.warnOnRestart''' and '''browser.showQuitWarning'''
    An alternative is to set Firefox to automatically open your last set of tabs when you start Firefox.
    # Open the Options window and go to the General panel
    # Change the setting "When Firefox starts" to "Show my windows and tabs from last time"
    As for the drop-down list on the back/forward arrows, you can get the drop down list by either right-clicking on the back/forward buttons, or holding down the left button until the list appears.

  • How to trigger Availability check in Sales Order 'save' user exit.

    I have requirements which dictate that I change item categories of most of the line items in a user exit. If I do that the line items no longer confirm. I know that the availability check happens in 'move_Field_to_vbap' user exit. Is there any way I can re-trigger it on save. These orders will be coming through a bapi. Thanks in advance.

    Hi!
    Search the way (via menu) in VA01 to trigger the availability check manually. Then have a look, with routines are called.
    Then call this (these) routines in the exit. If you see something like 'perform okcode_...', then this should work. Be careful not to trigger recursive loops by this way. Maybe  the prepare_save-exit is a better place to do this.
    Regards,
    Christian

  • Palm Desktop saves and exit very slow; losing data above letter "t"; duplicate records created

    Since I installed Palm Desktop by ACCESS (v. 6.2.2) on both an XP and a Vista Home Premium PC (one is a notebook, other a desktop), two critical issues have arisen:
    1) when I make any change in the records and save (File - Save all OR Control S), it takes about 45 seconds to complete the save. This is also how long it takes to exit the Palm Desktop. With previous versions of Palm Desktop, these functions took a couple of seconds. This problem exists with only a few records in the data base, as well as thousands of records. It has nothing to do with the McAffee program - tested that.
    2)  in the Contacts data base, every now and then, all data above the letter "t" disappears. I can recreate the missing data either from a backup of the data base or by doing a hotsync.
    3) every now and then, I discover that all records have been duplicated - this happens on both the PDA and the Palm Desktop. In this case, I need to use the latest backup files, load them into the Desktop, then do a hotsync with the Desktop overriding the Handheld.
    Any suggestions on what could be causing these problems? Palm's staff has been clueless. 
    Post relates to: Palm TX

    Lesson: Use the correct software version!
    Re-installed using PD414EN and all is good! Hurray!

  • Inability to export from Indesign and save over exiting PDF on Mac Yosemite

    When I export an InDesign document to save as a PDF, it only works if the PDF doesn't already exist. If I try to replace a file, I get the error File is Open. Needless to say, the file is not open. I'm using InDesign CC 2014 Release and a Mac updated to Yosomite 10.10.1. The files is on a Windows server 2008 and I have full permissions.

    Try doing it on your Desktop. It may have to do with permissions for saving to the server. I believe there is an ongoing thread about difficulties saving to Windows servers with Yosemite.

  • FB01 Save user exit

    Hi,
    Does anyone know of a user exit that gets activated when saving a document using transaction FB01. I need to exit to include structures containg all the information being posted in the financial document. Ive tried looking for enhancement in SMOD using package FBAS, but have not found anything suitable.
    Many Thanks
    Don

    Transaction Code - FB01                     Post Document
    Enhancement/ Business Add-in            Description
    Enhancement
    SAPLF051                                Workflow for FI (pre-capture, release for payment)
    RFKORIEX                                Automatic correspondence
    RFEPOS00                                Line item display: Checking of selection conditions
    RFAVIS01                                Customer Exit for Changing Payment Advice Segment Text
    FARC0002                                Additional Checks for Archiving MM Vendor Master Data
    F180A001                                Balance Sheet Adjustment
    F050S007                                FIDCCH Outbound: Influence on IDoc for Document Change
    F050S001                                FIDCMT, FIDCC1, FIDCC2: Edit user-defined IDoc segment
    F050S002                                FIDCC1: Change IDoc/do not send
    F050S003                                FIDCC2: Change IDoc/do not send
    F050S004                                FIDCMT, FIDCC1, FIDCC2: Change outbound IDoc/do not send
    F050S005                                FIDCMT, FIDCC1, FIDCC2 Inbound IDoc: Change FI document
    F050S006                                FI Outgoing IDoc: Reset Clearing in FI Document
    Business Add-in
    F050S008                                FIDCC1, FIDCC2 Inbound IDoc: Update Comparison Ledger
    FBAS_CIN_LTAX1F02                       Tax interface
    FBAS_CIN_MF05AFA0                       EWT - Downpayment Clearing - Tax transfer for CIN
    FISPLIT                                 Online Split: Cash Discount, Exchange Rate Differences
    FI_PAYREF_BADI_010                      BAdI: Payment Reference Number
    FI_RES_ITEM_CURRENCY                    Document of Residual Item with Invoice Currency
    FI_TRANS_DATE_DERIVE                    Derive BKPF-WWERT from Other Document Header Data
    FVFZ                                    Replacement for Function Modules of Function Group FVFZ
    INVOIC_FI_INBOUND                       BADIs for Inbound IDoc INVOIC FI (Vendor Invoice)
    RFESR000_BADI_001                       BAdI for Own Processing of POR Item
    FI_FB08_SUBST_BUDAT                     FB08: Check Posting Date for Reversal of FI Doc. with FB08
    FI_HEADER_SUB_1300                      Screen Enhancement for Document Header SAPMF05A
    FI_DOC_DISP_LI                          Diversion to Document Items (FB03)
    BADI_BRNCH_TO_BUDAT                     Deriving BUDAT based on BRNCH (ENJOY)
    BADI_ENJ_ALT_ADR                        Go to alternative vendor/customer data
    FI_AUTHORITY_ITEM                       Extended Authorization Check for Document Display (FB03)
    FI_GET_INV_PYMT_AMT                     BAdI for determining the payment amount for an invoice
    AC_QUANTITY_GET                         Transfer of Quantities to Accounting - Customer Exit
    ADJUST_NET_DAYS                         Change to Net Due Date
    BADI_F040_SCREEN_600                    Screen Enhancement on F040 0600 Document Header
    BADI_FDCB_SUBBAS01                      Screen Enhancement 1 on FDCB Basic Data Screen (010, 510)
    BADI_FDCB_SUBBAS02                      Screen Enhancement 2 on FDCB Basic Data Screen (010, 510)
    BADI_FDCB_SUBBAS03                      Screen Enhancement 3 on FDCB Basic Data Screen (010, 510)
    BADI_FDCB_SUBBAS04                      Screen Enhancement 4 on FDCB Basic Data Screen (010, 510)
    BADI_FDCB_SUBBAS05                      Screen Enhancement 5 on FDCB Basic Data Screen (010, 510)
    BADI_PRKNG_NO_UPDATE                    BAdI for Deactivating Update of Parked Documents
    No.of Exits:         13
    No.of BADis:         26

Maybe you are looking for

  • ITunes library help - moved to external drive and now my apps are gone?

    I moved my iTunes library to an external drive, but now my apps are gone? I do have iTunes match and iCloud, so my songs are all on the cloud, but none of my apps are showing... I copied everything over, consolidated, but I must have messed something

  • Connection between Oracle 9i and MS Sql Server 2005

    Hey Guys, I am hoping to create materialized view of data on a small sql server box using our oralce 9i cluster. Anyway, i have done this with mysql using the standard odbc dirvers and a dblink, but i am having trouble finding an odbc driver for the

  • Report to see  T CODE  use

    Hello  , is  there  some  report  when  we  can  see  how  many  times  users  have  used  some  of  the  transactions? Thanks and  best  regards L

  • Where is save as draft in toolbar for mail

    I know you can use save from the File pull down but it is so much easier to have it on the toolbar -where did it go? thanks for any help Theprin

  • Old computer broken...can I put ALL the stuff in my iPod on a new computer?

    Here's the deal..when I got my iPod 80GB Classic I had my iTunes on my laptop. I synched all my music, videos, and most of my pictures from the laptop to my iPod but soon after i did that the motherboard of my laptop went bad and so now I can't even