JFileChooser "Cancel" option

Hi,
i would be happy if nebody could show me thru this problem..
actually,i'm making a dialog,which has a "finish" button..as soon as the user clicks on it,a file save dialog pops up ..the problem is if the user clicks on "Cancel",exceptions are generated(in fact,a lot many!).what i want is that the initial dialog reappear.the codesnippet is below...
private void FinishActionPerformed(java.awt.event.ActionEvent evt) {
    // previous irrelevent part of the code
    String filePath = new String ("");
    String fileName = new String ("");
    File file = null;
    JFileChooser fileDialog = new JFileChooser ();     
    int dot;
    fileDialog.setFileFilter (new XMLFilter ());
    fileDialog.setMultiSelectionEnabled(false);
    fileDialog.setDialogTitle("SAVE AS");
    int returnVal = fileDialog.showSaveDialog (TextImportWizard3.this );     
    if (returnVal == JFileChooser.APPROVE_OPTION)
      file = fileDialog.getSelectedFile ();
      filePath = new String (file.getPath()) ;
      fileName = new String (file.getName());
      if (fileName.equals (""))
         JOptionPane.showMessageDialog (parent, "Please enter an XML filename.");
      else
         if((dot = fileName.lastIndexOf ('.')) == -1)
             StringBuffer temp = new StringBuffer (filePath);
             temp.append (".xml");
             filePath = temp.toString ();
      // do something.....                    
         xmlWriter = new XmlWriter();
         xmlWriter.createXML (XMLSchema,new File(filePath));
         // make the dialog disappear
         setVisible (false);
         JOptionPane.showMessageDialog (parent, "XML file saved.");
         disposeAll ();     // disposes all previous dialogs
looking forward to ur replies.
regards.

You should club the following code in a function:
public int myFunction()
fileDialog.setFileFilter (new XMLFilter ());
fileDialog.setMultiSelectionEnabled(false);
fileDialog.setDialogTitle("SAVE AS");
int returnVal = fileDialog.showSaveDialog(TextImportWizard3.this );     
if(returnVal == JFileChooser.APPROVE_OPTION) return returnVal;
else myFunction(); //recursively call this function till u get an approve response from the fileChooser.
private void FinishActionPerformed(java.awt.event.ActionEvent evt)
//Your normal code
int returnVal = myFunction();
if (returnVal == JFileChooser.APPROVE_OPTION)
//Your approve code
}// FinishActionPerformed ends
-Manish.

Similar Messages

  • How to remove save, cancel option when end user runs the workbook in Portal

    Hi,
    how to remove save, cancel option when end user runs the workbook and make some small changes like using page items or increasing rows and columns
    I already made 2 changes
    1) I removed the option in Oracle Enterprise Manager under discoverer viewer of saving
    2) I also removed the option of Allow saving changes made in Viewer when adding workbook to portal
    But still the end user gets options of saving when made small changes to workbook like increasing rows and columns
    Is their any place, I need to make changes?
    Thanks in Advance
    Rowdheer

    Don't use JSP to serve a binary file. It almost implies the use of awful scriptlets and the invocation of both the response writer and the response outputstream which would only lead to IllegalStateException headaches in the server logs.
    Use a Servlet instead. Specify the file name as request parameter and let the servlet read the file and write it to the outputstream of the response.

  • I want to download and install adobe flash player. When I do so one occur. A dialog box appears but it has no run option but a save file or cancel option.

    # Question
    I want to download and install adobe flash player. When I do so one of 2 things occur. A dialog box appears but it has no run option but a save file or cancel option. The other is if the proper dialog box appears, I agree and the a different box appears and there is foxfire with a red circle with a diagonal line across is appears.

    I find the easiest way to install Adobe Flash is to use the manual installers. You just need to download the installer to your computer, then run it to install Flash. For more details see http://kb2.adobe.com/cps/191/tn_19166.html#main_ManualInstaller
    That link states you should uninstall earlier versions, as you don't have the version of Flash used by Firefox you can skip that step.

  • Controlling approval status report cancel option

    Dear Experts,
            Is it possible to control the approval status report screen based on Stored Procedure?
            Im having problem with users cancelling their draft documents before any approval status is decided upon the draft. Through the images below i want to control the cancel option they have
    can the update button be controlled through store procedure? as I cant get the object type of this screen.
    thanks in advance
    Regards,
    Balwant

    Hi,
    is the approval status report which can be set as read only in SAP B1 9.0 and above?
    Cause currently im using SAP B1 8.82  Pl 13 and cant set read only
    Regards,
    Balwant

  • Noise Cancellation option is Missing in 5C

    Hi,
    I just bought a new iPhone 5C (by the way, I am located in India, so is this phone) and notice that "Noise Cancellation" option is missing and also when I turn on the "Reduce Motion", I still see that the Parallux effect is still on.
    How to fix these two issues?

    Hi Amit.
    For the same fieldcatalog define data type as INT4.
    For eg.
      wa_fieldcat-fieldname    = 'Integer'.
      wa_fieldcat-do_sum       = 'X'.
      wa_fieldcat-datatype     = 'INT4'.
    and in the layout.
    wa_layout-totals_only = 'X'.
    wa_layout-subtotals_text = 'Subtotal of Integer'.
    I hope this will work.
    Best Regard,
    Nikhil Patil
    Edited by: Nikhil Patil on Jan 24, 2011 9:13 AM

  • No option to Open downladed file - just Save As or Cancel options

    If you want to download any file in IE11 there is no option to OPEN the file. Only two options are to SAVE or Cancel no option to OPEN.
    The question: Is there a way to set IE11 via GPO to show the OPEN option in addition to SAVE and Cancel options. 

    Hi,
    what type of file?
    File types have an 'opener' application associated with them... for example pdf documents (*.pdf) are opened in an ActiveX PDF view application...outcomes for ActiveX 'openers' can in turn be affected by say your Adobe PDF Reader settings or your IE ActiveX
    Filtering settings.
    additionally there are security zone settings that affect opening and downloading different file types... some file types are recognised as dangerous (eg. exe, com, pif, mdb)...
    You GPO security zone templates may affect client outcomes.... Ensure the client is accepting the default IE Security zone settings (Security tab of internet Options>Click "reset all zones to default")
    Rob^_^

  • Error message with Cancel option

    Hi,
    When i create a sales order, While saving, i need to do a price check and display error accordingly. I did this coding in the user exit MV45AFZZ. But this error msg terminates the transaction. User wants a cancel option in the error  msg so he can go back to the screen and edit the data.
    So I created a pop up displaying the error msg having cancel button. When cancel button is clicked it goes back to the screen.
    But the issue is when i again click the save buttion, the user exit doesnt trigger. It continues from the code where it left.
    How to overcome this?
    Ezhil.

    MV45AFZZ is not a user exit; it's an include program with subroutines that are called as user exits.  Which user exit subroutine did you use?  Most of the exits do not terminate the transaction on an error message, including USEREXIT_SAVE_DCOUMENT_PREPARE.  You don't need a pop up.

  • Exit button is not popping Quit/cancel options in application (.exe)

    Hi,
    I have created a VI with Exit button using run time menu option
    When I run same VI and click on Exit button, it popups a message with Quit or cancel options
    Then I created .exe for the same VI and executed, when i click on exit button it is directly quitting labview with out any popup message
    Can some one help me in creating .exe with quit/cancel popup message
    Thanks in advance

    Oh, you are calling the LabVIEW IDE's Exit.  Do not do that.  With that you are aborting any running VIs (ie, not letting them stop on their own) and shutting down LabVIEW.
    I recommend you use an Event Structure to handle the pressing of the exit menu item and doing whatever you need to inside that event case.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to handle the cancel option of the showInputDialog

    Hi guys,
    I wonder how to handle the cancel option of the showInputDialog. Let is say i am getting a n input from the user and instead of entering any data he cancels the opterations ..
    how to cope with it?
    abdul

    Test for null!
    Example:
    String name = JOptionPane.showInputDialog(parent, "Type your name", "Name Dialog", JOptionPane.INFORMATION_MESSAGE);
    if(name != null) {
    //if the user clicked ok, write action code here...
    } else {
    // the user click cancel, do what you need here...
    Hope this helps!

  • Cancel option of Reconciliation and Link Invoice

    Hi !
           We by mistake have Linked Invoice with wrong amt. ie we linked invoice of value 1 lakh with 10000 payment. unfortunately the invoice got closed. How to reverse the linked invoice ?
    similarly we need to know the reversal options for reconciliation.
    shiva.

    payment-cancel incoming/outgoing payment.
    reconcillation-manage previous reconcillation.
    Jeyakanthan

  • No cancel option on the meeting setup by delegate

    I have two issues:
    1) The delegate (name : xyz)  appears as the meeting organizer " Organizer: xyz on behalf of abc" . This does not seem normal.
    2) And then the mailbox owner ( abc) does not have option to cancel these meetings.
    To make matter worse the delegates mailbox and account was deleted before finding this issue.

    Hi,
    Please access the webmail to check whether the mailbox owner can cancel the meeting or not. Generally, if the meeting is created by the delegate, the From field would be shown as "Delegate on behalf of Manager" in Inbox folder. But the organizer of the meeting
    in Calendar would shows "Organizer: Manager" instead of "Organizer: Delegate on behalf of Manager".
    Please make sure there are no third-party devices used for managing calendar. And add the delegate back to check whether the issue can be reproduced.
    Regards,
    Winnie Liang
    TechNet Community Support

  • Add an Event in Web dynpro for Cancel option

    Hi Everyone,
    I have a scenario where in which , I have a search help option and when users hits of search help a window pops up and when user selects any it populates the data into feild.
    Now that i want to add a cancel button in the F4 window .
    How can  go about and do this.
    Please provide me step by step approach as most of the web dynpro I am not aware of... i am new and learning on my own.
    Regards,
    Raj

    Kandaraj,
    Using window instance you can implement the cancel functionality,
    Create a context in your component controller "WindowInstance" with the type type     "com.sap.tc.webdynpro.services.session.api.IWDWindow"
    User this method in you component controller,
    /**********************COMPONENT CONTROLLER***************************
    public void showpopup( )
    IWDWindowInfo winInfo = wdComponentAPI.getComponentInfo().findInWindows("PopupWin"); // PopupWin -> Name of your window
        IWDWindow win = wdComponentAPI.getWindowManager().createModalWindow(winInfo);
        win.setWindowPosition(300,150);
        win.setTitle("Your Account Infomation");
           win.setWindowSize(200,200);
        wdContext.currentContextElement().setWindowInstance(win);
        win.show();
    call the method from the View
    *************Create a Window for Popup*************************
    Create a View for New Window
    Create a context in your component controller (Popup Window) "WindowInstance" with the type type     "com.sap.tc.webdynpro.services.session.api.IWDWindow"
    Open the View of Popup Window
    Create a Button and action for the button
    Put this code inside the action method:
      IWDWindow win = wdContext.currentContextElement().getWindowInstance();
        win.close();
    Ram

  • Cancelation options?

    Hello.
    If we have a BT Broadband and Phone line package which are pretty early in their contracts, can I cancel [we signed up about 6 months ago however we have just upgraded to the next package up as we were hitting our limit each month, which no doubt enters us into another long contract]…
    …we are about to move to a new place however the landlord provides the phone and internet services so we wouldn’t be able to move our package to the new address – I don’t want to be hit with 24 months of changed to terminate our contract and the landlord is currently locking in for another year so he’s not prepared to cancel his contract.
    I wouldn’t have signed up if I knew we’d be moving so soon but sadly due to situations beyond our control we have to be out by the end of the month.
    …any thoughts?
    Solved!
    Go to Solution.

    The only way to find out what your options are is to give BT a phone and ask  them. I don't think we could answer this accurately on the forum.
    Life | 1967 Plus Radio | 1000 Classical Hits | Kafka's World
    Someone Solved Your Question?
    Please let other members know by clicking on ’Mark as Accepted Solution’
    Helpful Post?
    If a post has been helpful, say thanks by clicking the ratings star.

  • JFileChooser Cancel Button

    Hi,
    Is there a way to change cancel button text in a JFileChooser?
    Reguards,
    Nuno Martins

    The cancel button uses a value from the UIManager, "FileChooser.cancelButtonText". Replace that value via UIManager.put(key, value) with whatever you like. Almost all these types of properties can be changed. Look in the cooresponding plaf classes (BasicFileChooserUI.java, MetalFileChooserUI.java, ...) for what other components use.

  • I see that canceling membership seems to be a common issue. I have followed all of the steps that were given but there is no cancel option given to me. My account says I am on a 1 year free membership as a student yet I am being billed $19.99 every month.

    THE WEB SITE INSTRUCTIONS ARE POOR. THEY SAY TO CLICK THE STILL NEED HELP BAR BUT THIS CYCLES ME BACK TO THE FORUM? IS THERE A PHONE NUMBER WHERE AN ACCOUNT REP CAN HANDLE CANCELATION DIRECT
    Y?

    Moving this discussion to the Adobe Creative Cloud forum.
    Xxxhhhhgggg for information on how to cancel your membership please see Cancel your membership or subscription | Creative Cloud - http://helpx.adobe.com/x-productkb/policy-pricing/cancel-membership-subscription.html.  If you are not receiving an option to speak with a member of our support team then please utilize a different web browser, computer, mobile phone, or tablet.

Maybe you are looking for

  • Do 'temporary' EJB exist to avoid writing database?

              Hello, I have a kind of entity EJB which has short-life (it is created, stored           in the database for 5 minutes, and then deleted).           Furthermore, the persistence of this EJB is not important (in case of system crash         

  • I want to create a formula in numbers that gives me an ongoing monthly average

    I've created a spreadsheet to track my MPG, and I'm also logging all maintenance bills too. What I want to do, is get an idea of how much the vehicle is costing me on a monthly average. I want this to be ongoing over several years and therefore want

  • Cfquery to javascript array to .js file

    Hi guys, I've got a small problem out there: have cities table in the database therefore pulling out everything using cfquery . <cfquery name="get_city" datasource="IGES"> SELECT * FROM cities ORDER BY City ASC </cfquery> Now all these city names fro

  • Programmatically creating VM from already created image using Java

    Hello. I am writing a Java program to create VMs from already created VM images. I was able to create through the web portal. I am using the API given here http://msdn.microsoft.com/en-us/library/jj157194.aspx The request sent is <?xml version="1.0"

  • Problem with a script

    I can be reached at [email protected] I had a question for you to see if you can solve. I have a script below I am trying to run in Oracle 9i SQL+ with SYSTEM/MANAGER privileges. Is the script look complete to you? For some reason I get insuffici