Set default filename in JFileChooser (Save Dialog)

Hi,
how can i set a default filename in a JFileChooser-Save-Dialog?
The file does NOT exist, so setSelectedFile(new File("FileName")); does not work.
Thanks in advance.
Filo

Did you test this? It works fine for me.

Similar Messages

  • Set default filename for file save dialog

    Hi,
    I am using AxAcroPDF control to view pdf files in windows forms.
    Is there any option to set the default filename in the save dialog?
    Thanks for your help.
    Freedon

    Hi,
    I've found a solution.
    public void Open(string filePath)
    axAcroPDF.LoadFile(filePath);
    //this will set the correct name in the save file dialog.
    axAcroPDF.src = filePath;
    Thanks for your help.
    Freedon

  • Set default filename for file save dialog on Save button click

    Hi,
    I am using AxAcroPDF (version 9.0) control to view pdf files in windows forms (C#). The pdf loads into the viewer in the form. Now, when I click on the Save button in the viewer, a Save dialog pops up with a default filename having complete path info.
    If I have loaded the pdf file into AxAcroPDF viewer with filename:
    "C:\Documents and Settings\KB_Kravi\My Documents\CustomerList.pdf"
    then in the save dialog, the default filename will be:
    "C_Documents_and_Settings_KB_Kravi_My Documents_CustomerList.pdf"
    Is there any option to set the default filename in the save dialog to some short name, instead of this lengthy name?
    Thanks,
    Ravi.

    Hi,
    I've found a solution.
    public void Open(string filePath)
    axAcroPDF.LoadFile(filePath);
    //this will set the correct name in the save file dialog.
    axAcroPDF.src = filePath;
    Thanks for your help.
    Freedon

  • Set default directory/path for SaveAs Dialog using WPG_DOCLOAD

    Hi, im trying to set the default directory/path for the SaveAs Dialog called by wpg_docload.download_file.
    I'm not able to find where I can specify the default path.
    Is it something like "htp.p('Content-Disposition: attachment; path=:PX_OUTPUT_DIR" ?
    Thx for your help !
    Here's a part of my code
    owa_util.mime_header( NVL(mime,'application/octet'), FALSE );
    htp.p('Content-length: ' || length);
    htp.p('Content-Disposition: attachment; filename="'||substr(fileName,INSTR(fileName,'/')+1)|| '"');
    owa_util.http_header_close;
    wpg_docload.download_file( lobLoc );
    /*********************/

    I don't believe you're allowed to set the directory path in the Content-Disposition (or any other) header. More accurately, you can set path in the filename, but browsers don't pay any attention to that, they only look at only the terminal filename.
    <p>According to RFC 2183, browsers are supposed to ignore any path information sent with the filename. Even though it's dated 1997, I believe this RFC is still in effect.
    <p>This was done as a security precaution against malicious web apps that might try to download into a system directory or other dangerous place. Also, browsers (usually) allow users to specify their own default download directories. Further, even if you could specify the path, you'd have to do it for any and all filesystems (Linux, Mac HFS, Mac OSX, Windows, etc etc).

  • How to set default file type for Open dialog

    Dear my friends,
    I am using "At selection-screen ON VALUE-REQUEST FOR filepath" to display open dialog and i want to set default file type for open dialog = *.txt.
    Thank your times !

    Hello,
    U can make use of this code:
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR SP_FILE.
      PERFORM SAVE_DIALOG CHANGING SP_FILE G_F_RC.
    FORM SAVE_DIALOG CHANGING PO_FILE PO_RC.
      DATA: L_VA_BOXTITLE     TYPE STRING,
            L_VA_DEFAULTFILE  TYPE STRING,
            L_VA_DEFAULTNAME  TYPE STRING,
            L_VA_DEFAULTPATH  TYPE STRING,
            L_VA_DEFAULTFULL  TYPE STRING,
            L_VA_FILTERTEXT   TYPE STRING,
            L_VA_CODE         TYPE I.
      CLEAR: PO_RC, G_F_CONF.
      L_VA_BOXTITLE   = TEXT-B01.
      L_VA_FILTERTEXT = TEXT-B02.
      IF PO_FILE IS INITIAL.
        CLEAR L_VA_DEFAULTFILE.
      ELSE.
        L_VA_DEFAULTFILE = PO_FILE.
      ENDIF.
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
        EXPORTING
          WINDOW_TITLE            = L_VA_BOXTITLE
          DEFAULT_EXTENSION       = 'TXT'
          DEFAULT_FILE_NAME       = L_VA_DEFAULTFILE
          FILE_FILTER             = L_VA_FILTERTEXT
          INITIAL_DIRECTORY       = 'C:SAPWorkdir'
        CHANGING
          FILENAME                = L_VA_DEFAULTNAME
          PATH                    = L_VA_DEFAULTPATH
          FULLPATH                = L_VA_DEFAULTFULL
          USER_ACTION             = L_VA_CODE
        EXCEPTIONS
          CNTL_ERROR              = 1
          ERROR_NO_GUI            = 2
          OTHERS                  = 3.
      IF SY-SUBRC <> 0.
        PERFORM CHECK_ERRORTYPE(Z48M_MATDATA_UP) CHANGING SY-MSGTY.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        CLEAR PO_FILE.
        EXIT.
      ENDIF.
      IF L_VA_CODE NE 0.
        MESSAGE S818(3F) WITH TEXT-011.
        CLEAR: PO_FILE, PO_RC.
        EXIT.
      ELSE.
        WRITE L_VA_DEFAULTFULL TO PO_FILE.
        G_F_CONF = G_C_XFELD.
      ENDIF.
    ENDFORM.                    " save_dialog
    If useful reward.
    Vasanth

  • How to set default file path for save

    Hello all,
    I'm currently blocked on the below issue and is hoping to gain your help and insights.
    We have recently upgraded to InDesign CS6. Now when an INDD file created in an older version of INDD is opened in CS6, all the save dialogs would not default to the location of the original INDD file. Though if the same file is opened in the version of InDesign that created it, the save dialog goes to the proper location by default.
    Debugged using our custom plugin as a gate way, and found out that after InDesign CS6 performed the document upgrade/convert, the database for the converted document loses file information. i.e.  IDataBase::GetSysFile() returns nil. I think we can figure out some way to get the original file path. For example, we can intercept "kAfterOpenDocSignalResponderService", and get the original file path of the opened file from IDocumentSignalData. Though I haven't yet able to figure out a safe way to set this file path to the document, so that the save dialogs would by default point at this path.
    Utils<Facade::IWorkgroupFacade>()->InitDocumentAssetManagement(docRef, filePath) seems to do the right thing, but it seems to be quite intruding, and I'm afraid that it is overkilling and will cause bad side effect for the use case I'm looking for.
    So I'm wondering if anyone has any suggestions to achieve this without implementing/overriding the file save dialog.
    Thanks.
    -Jeff

    You should be able to avoid writing your own open-doc trap by using kDocBoss's IOpenedFileInfo to obtain the original file's path. It seems fairly reliable; the only time I've seen it come up empty is for an opened QuarkXPress document.
    I'm afraid I don't know of a sanctioned way to change IDataBase::GetSysFile() without going through the database's SaveAs machinery. Overriding this behavior might only be possible by replacing the regular Save dialog with your own.
    But if InitDocumentAssetManagement() is helping, maybe the workgroup/asset management approach is worth pursuing. Have you tried spying on that call in the debug app? You might be able to isolate and use one of the commands that it's invoking (IAMSPManager::BindAsset() / kSetAssetAttributesCmdBoss?) without all of the side-effects of the higher-level call.

  • Setting default filename for servlet-based download

    I'm new to servlet programming and am attempting to download a file from the server to the client. When I am prompted to open the file from it's current location or save it to disk, the correct filename appears. However, when I click ok and the Save dialog appears, the default filename isn't the actual name of the file but instead contains the name of the package the servlet is located in. Can anyone tell me how I can change my code to have the default filename appear instead of the package name. Thanks.
    Here is the code to call the servlet located in the package named 'frosttwo':
    WebgapBeanFactory wgbf = WebgapBeanFactory.getWebgapBeanFactory();
    String path = wgbf.getTransferFileDirectory();
    String filename = path + request.getParameter("file");
    System.out.println(filename);
    response.sendRedirect("/servlet/frosttwo.Servlet1?file=" + filename);
    Here is the code contained in the servlet:
    public class Servlet1 extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html";
    /**Initialize global variables*/
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    /**Process the HTTP Get request*/
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String file = null;
    try
    file = URLDecoder.decode(request.getParameter("file"));
    String filename = file.substring((file.lastIndexOf(File.separatorChar) + 1), file.length());
    response.setContentType("application/octet-stream");
    response.setHeader("Content-disposition", "attachment;filename=" + filename);
    File f = new File(file);
    FileInputStream is = new FileInputStream(f);
    ServletOutputStream s = response.getOutputStream();
    byte[] buffer=new byte[8192];
    int length=buffer.length;
    while((length=is.read(buffer))!=-1)
    s.write(buffer,0,length);
    s.flush();
    catch (IOException ex)
    System.err.println("There was an error sending file " + file);
    ex.printStackTrace();
    catch (Exception ex)
    System.err.println("There was an error sending file " + file);
    ex.printStackTrace();
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doGet(request, response);
    /**Clean up resources*/
    public void destroy() {
    Thanks again.

    I use something like this for res.setHeader and it works fine for me. In the save dialog box it puts this filename there. But if its not able to find the filename then sometime it used to put servletname instead of filename:
    res.setHeader("Content-Disposition","multi-part attachment;filename=\""+
    fname+"\";");
    hope it helps
    vinod

  • Set Default Values in Listbox with Dialog Programming

    Hi all,
    I am stuck with a problem i.e  I am working with Dialog Programming Screen
    where i have to set default values in some n numbers of Listbox which i have created on Screen.
    This default value is needed to be fetched from database table.
    I am using single table. Hence no confusion that i have to first fetch data from 1st listbox then corresponding data is fetched into second & so on ..NO NO This is not required.
    Simple one screen which will update a table in database, where  some fields on the screen needs to be default set as per tables domain default values set while table creation.
    Please help me out in this.
    Thanks & Regards,
    Sandhya.

    Please search SDN, before you post a new forum from next time... any ways just follow the below code..
    u need to use the FM 'VRM_SET_VALUES' to implement list box in module pool. Check the below code. u have to write this code in PBO..
    if c = 0.
    select land1 landx from t005t into table wi_country.
    sort wi_country by land1.
    delete adjacent duplicates from wi_country comparing all fields.
    loop at wi_country.
    wa_ctry-key = wi_country-land1.
    wa_ctry-text = wi_country-landx .
    append wa_ctry to wi_ctry.
    endloop.
    call function 'VRM_SET_VALUES'
    exporting
    id = 'ZCUST_MASTER1-COUNTRY'
    values = wi_ctry
    exceptions
    id_illegal_name = 1
    others = 2
    if sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    c = 1.
    endif.
    Hope this helps u,
    Regards,
    Rajesh

  • Default file name in Save dialog

    In our application, we need to specify a default name when
    calling file.browseForSave("Save"). However, it seems impossible.
    file.resolvePath("<path>") does not help as if the
    specified path does not exist, it throws out an error.
    Anyone can help? Thanks in advance!

    Thank you for your reply. I did try that. However, the
    problem is the similar to using file.resolvePath("<path>").
    In var f:File = new File( "/path/to/yout/file.txt" ), if
    "/path/to/yout/file.txt" is not an existing file on the disc, there
    will be the following error:
    ArgumentError: Error #2004: One of the parameters is invalid.
    at Error$/throwError()
    at flash.filesystem::File/set nativePath()
    at flash.filesystem::File()
    When saving data to a file, the file may not exist on the
    disc...

  • Set default reader extened to save a pdf form using reader?

    is there a way to set it so all forms created are Reader exteneded so they can be saved. why is that shut off anyway? I want them to be able to save it and send it back to me? So now I have to go in an manually open each one andclick several options save it "AND" as a new file as well.

    You have to create it yourself using a folder-level JavaScript. The script would use the app.addToolButton method to create the toolbar button and app.execMenuItem to trigger the corresponding menu item (e.g., Advanced > Extend Features in Adobe Reader or File > Save As > Reader Extended PDF > Enable Additional Features.) For more information, see:
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.134.html
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.143.html

  • JFileChooser Save Dialog

    When you call the JFileChooser's showSaveDialog method, what is the best way to allow the user to enter a new file name? It seems like that if they enter a new file name into the text box, getSelectedFile () won't work, so how do you create a new file out of what the user has entered in the text box?

    This is how it looks
    JFileChooser chooser = new JFileChooser();
    cfc(chooser);
    private void cfc(JFileChooser fc)
         for(int i=0; i < fc.getComponentCount();i++)
              if (fc.getComponent(i) instanceof JPanel) ojp((JPanel)fc.getComponent(i));
    private void ojp(JPanel jp)
         for(int j=0; j < jp.getComponentCount();j++)
              Component bo = jp.getComponent(j);
              if (bo instanceof JPanel) ojp((JPanel)bo);
              if (bo instanceof JButton)
                   if (((JButton)bo).getText().equals("Open"))
                        bo.setBackground(Color.green);
                   if (((JButton)bo).getText().equals("Cancel"))
                        bo.setForeground(Color.red);
    Noah

  • Acrobat PDF Printer STILL freezes when pasting filename into Save dialog

    Ref: Acrobat Printer Freezes on Save when CTL+V is used
    No change in Acrobat X.  Printing system still freezes up entirely when pasting a filename into the Save dialog, when printing to Adobe PDF printer.  Most often from Firefix (all versions through 28.0) but from other programs as well (also happens from MS Outlook 2010 32 bit).
    Any chance of an update from Adobe?
    Acrobat Pro X on Win 7 64 bit.  Multiple systems exhibit same behavior.
    Same issue occurs in Acrobat XI Standard.
    Workaround is possible by manually typing in filename, or renaming, but clearly this should not be happening.  If you forget, it requires a lot of steps (or a reboot) to try again.

    If you copy text directly from FireFox (or Word, or pretty much any program, other than Notepad), and try to paste into the Save Dialog to save your PDF, guaranteed crash.
    HOWEVER, if you paste the text into Notepad first, and then copy it again, you can then paste into the Save dialog no problem.  This is why the "test" that the Adobe rep did to recreate the problem was pointless: He managed to re-create the one workaround method that DOES work, instead of actually trying to do things the way that were causing the issue to show up.
    The problem appears to be related to any sort of "rich" text.  Windows ignores the "rich" information and only keeps the text if you paste into a filename in the system.  So Windows handles it just fine, it's Adobe's save dialog that can't handle it.  Copied text from Firefox is usually pretty clean (IE is worse), but there must be some formatting remnants in there that are giving Adobe fits (instead of properly ignoring them).  It may have something to do with 64-bit Windows and 32-bit Firefox and 64-bit Acrobat all coming together?  Copying and pasting between 64-bit and 32-bit programs usually has no issues, but in this case, it does (although the 64/32 bit relation is pure speculation on my end).
    But by "washing" your text through Notepad first, it completely strips it down to truly pure plain text, which can then be pasted into Adobe's Save dialog without a crash.  This adds an extra step, and should be entirely unnecessary, but it does work.  At least until Adobe fixes their program.

  • Issue changing CutePDF default filename

    Hi,
    Does anyone know how we can change the naming convention for filename in CUTEPDF SAVE dialog box?
    Our basis has set up device type 'PDF1' in SPAD and tie this to output device 'XX_PDF'. When we go to VA02 to issue output, if we set the print parameter output device 'XX_PDF', and print immediately, a pop up message box to save the PDF file will be displayed. The filename was defaulted <USER NAME>_<JOB SPOOL NAME>.
    Our requirement is to display sales order number instead of spool id.
    Is this possible to change via print program or any SAP setting we can do to change the naming convention of the PDF default file name?
    Can you please kindly help?
    regards,
    Xiang Li
    Edited by: xiangli heah on Nov 10, 2010 8:46 AM

    Sorry, but that's not something over which the user has any control. You can, by editing a setting in the preferences file, eliminate the track number, but you can't change anything else. If you want that sort of control over how the files are named, you may wish to use a different utility to do the CD ripping and then add the tracks to iTunes. Max (donationware) allows a lot of flexibility in how the files are named.
    Regards.

  • Turn off save dialog box when the close command is executed

    I would like to set the default value of the save dialog box to No when my users close my form, so they do not have to manual answer this question.  Is it possible to do this or is there a commmand I can place in docClose to tell the form to close without saving?
    Thanks
    -Anne

    The Downloads folder defined in Mail/Prefs/General is just to temporarily store decoded attachments.
    The Save dialog is available by pressing *and holding* the Save lozenge button next to the attachment(s) in the message header header, or right-clicking/save attachment on files visible in the message body.
    (Having to click and hold the save button to get something useful is extremely bizarre, and IMO broken)
    You can also drag and drop items from the message to a Finder window or whatever.

  • Setting default save file in JFileChooser

    Is there a way to set a default file name for the save dialog created by
    JFileChooser.showSaveDialog(null);in order to save the user needing to type something every time?
    Thanks.

    Exactly
    Java keeps ramming classes into the jre that are useful in only a very limited context. At the same time, they can't give us a filedialog that adds the extension onto the returned file... This is something everyone wants, but unfortunately is'nt part of Java. I'm frustrated by it as well (if you can't tell)

Maybe you are looking for