JFileChooser "File Name" field

Hi,
I am trying to use a JFileChooser as a component within a JDialog, and everything works fine, except that I do not understand how I can get the value of a filename typed into the "File Name:" field on the form. I've read the "JFileChooser" Java doco about five times and I can't see anything that would give me access to this field. GetName() appears to be a red herring.
Anyone got any ideas?
Thanks,
Tim

Thanks for your swift reply.
Unfortunately perhaps I wasn't quite clear - I have added the JFileChooser as a component to a JDialog, not run it standalone via showDialog() or similar.
I am trying to get the user to select a directory and type a file name that a new file can be saved into.
Here is the code that displays the chooser:
   private JPanel saveFilePnl(String folder)
      JPanel panel = new JPanel(new BorderLayout());
      panel.add(new JLabel("<html>Select the folder to save the new sequence into,<br>" +
                           "and type in an appropriate File Name:<br>"),"North");
      saveFileChooser.setCurrentDirectory(new File(folder));
      SimpleFileFilter filter = new SimpleFileFilter("xml", "Nucleotide Sequences"); 
      saveFileChooser.setFileFilter(filter);
      saveFileChooser.setControlButtonsAreShown(false);
      saveFileChooser.setBorder(BorderFactory.createCompoundBorder
                            (BorderFactory.createEtchedBorder(),
                             BorderFactory.createEmptyBorder(8,8,8,8) ));
      panel.add(saveFileChooser, "Center");
      return panel;
}This panel is added to a card on a CardLayout JDialog. After the user selects a folder and types in a filename I want to verify that they have done so before moving on to the next card. So I need to ensure that there is a name in the "File Name:" field on the chooser.
Thanks,
Tim

Similar Messages

  • Can JFileChooser file name field return all entered chars

    In JFileChooser, if I want to get all entered characters from file name field, is there a method I can call?
    I used method chooserUI.getFileName() or chooser.getSelectedFile(). These two methods returned texts which missed back slash and forward slash. I want to get everything what I entered in file name field. I searched and read related JFileChooser topic, but there isn't a topic about this. Can any of you know what I can do?
    Thank you very much.

    JFileChooser isn't for entering text, it's for selecting files. If you put for example "abc/def" in the filename box, it's going to interpret that as "file def in directory abc" and your getFileName() will return "def". (You'll notice that getFileName() doesn't return the directory path, just the filename part of it, right?)

  • File name field not generating dynamic file name for report printing

    Hello Folks,
    I have a report region on a page and have enabled report printing. I would like to have the file name generated dynamically. So, I add the substitution string, say "&P1_CUSTOMER_NAME." (no quotes). The output file I get is literally named "&P1_CUSTOMER_NAME..pdf" (no quotes).
    I have seen several posts suggesting the file name field should accept this syntax but, I cannot get it to work.
    We are running Application Express 3.2.0.00.27 and BI Publisher.
    Any suggestions?
    Thanks for your help.
    -Markus B.

    I was finally able to make it work using a page process and the APEX_UTIL.DOWNLOAD_PRINT_DOCUMENT with a submit button.
    -Markus B.

  • LabVIEW 2011 file selection fails to fill in the file name into the "File name:" field

    In LV2011 I am selecting a text file while my code is running. The "file name:" field is not populated with the selected file name.
    This is inconvenient, especially if I want to modify a file name by one or some few characters.
    How do i make LV 2011 behave like the previous versions?
    Scientia est potentia!
    Attachments:
    File name is not filled in.PNG ‏72 KB

    Thank you fot your reply it causd  me to find the problem.
    I figured it out while I was trying to extract the applicable section of my code to send it to you.
    I had an asterisc wired to the "default name" input of the "File dialog" VI.
    Now I am not wiring anything to the "default name" input of the "File dialog" VI and it works just fine.
    I am sorry for your lost time.
    Scientia est potentia!
    Attachments:
    Corrected code.PNG ‏10 KB

  • How Does The Browser Know The "File Name" field in the "Save As" dialog

    Hi!
    I have a servlet called co.com.SomeStaff who reads a binary file from the server an sends it to the breowser.
    The Browser opens the "Save As" Dialog whith the value "co.com.SomeStaff" in the File name field, but and I need the name "SomeBinariFile.exe" instead.
    How can I change that value?
    Thanks All.

    Use <%
    response.setHeader("Content-Disposition", "attachment; filename=filename.2save");
    %>

  • I have difficulty pasting text into the file name field(prefix only) while saving files.

    OS: WinXP sp3
    FF: 3.6.3
    I have difficulty pasting text into the file name field (prefix only) while saving files. example: File name is Pic123.jpg and I want to rename it ABC123.jpg and I have ABC loaded into the WinXPsp3 clipboard. When I highlight\right-click\delete "Pic" then attempt to paste the ABC, I get either no reaction, or upon multiple paste attempts, the ABC is appended to the end of the file, after the extension, as "Pic123.jpgABC". If I delete this unwanted suffix, or repeat the process several times, eventually I can delete the unwanted portion of the prefix and paste the desired text. Sometimes it works fine first try, but mostly it takes several tries. I'm using Firefox 3.6.3 but the problem existed in whatever previous version I had too. This issue only occurs when using the delete/paste; I can always manually change the name by typing. Thank you for your help.

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    A possible cause is that the server sends a wrong response header.
    The server may not comply to RFC 5987 and sends a wrong Content-Disposition:attachment; filename header.
    * https://developer.mozilla.org/en/Firefox_8_for_developers#Network

  • FileChooser - "switch off" file name field and file type drop down choice..

    Hi there,
    I'm wondering, is there a simple way of not displaying the file name field and file type drop down choice that anyone knows of?
    Reason being; my FileChooser is embedded in an application window and does not pop up as a dialog - the users are only acessing one file type, but it could be in any folder on their machine.
    many thanks,
    Fergus.

    Moved to legacy SDK forum

  • JFileChooser file name extention queistion

    hi i would like to know if it is possible to place a file extention in the filename section when you open the save dialog. So as when the user types a file name in the file extention is added automaticly to only allow the user to save in .png. My code is as follows.
    private void screenshot()
              /** currently no dialog to confirm action as remains
              on screen when saving screenshot! **/
              int status;
              JFileChooser fc = new JFileChooser();
              fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
              try {
                        Rectangle rect = new Rectangle(Toolkit.getDefaultToolkit ().getScreenSize ());
                        BufferedImage image = new Robot().createScreenCapture(rect);
                        try {
                             fc.addChoosableFileFilter(new PNGFilter());
                            status = fc.showSaveDialog(information);
                            if(status == JFileChooser.APPROVE_OPTION)
                            File selFile = fc.getSelectedFile();
                            ImageIO.write(image, "png", selFile);
                            JOptionPane.showMessageDialog(information, "File saved to "+ selFile);     
                        } catch (IOException e) {
                                  Error.SaveError(e);
                        catch (AWTException e) {
                             Error.AbstractWindowToolkit(e);
    }

    You can always check selFile's name, and if it
    doesn't end with .png replace it
    with a new File with the same name, but with .png
    added on.Thanks for that. I have done just that and it works great now.
    if(getExtension(selFile).equals("NO_EXTENSION"))
                               selFile = new File(selFile.toString() + ".png");
                           }

  • JFileChooser File Name

    Hi!
    I'm using a JFileChooser to save in a local folder a file stored in my database and I'd like to set the File Name when I open the FileChooser, do you know how to do it ??
    Thanks !!
    TLLI

    JFileChooser.setSelectedFile()?

  • When downloading a file, only the first word of the attached file is included in the 'file name' field, not the entire file name, as it used to.

    Regardless of filetype, only the first word of the file is filled into the "Enter name of file to save to..." dialog box. I'm set up to 'save file' in the FF Options > Applications tab for the basic MS and Adobe files. To successfully use/find the downloaded file, I type in the remainder of the file name. Have I overlooked an additional setting? Running FF 18.0 on a Win7 PC.

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    A possible cause is that the server sends a wrong response header.
    The server may not comply to RFC 5987 and sends a wrong Content-Disposition:attachment; filename header.
    * https://developer.mozilla.org/en/Firefox_8_for_developers#Network

  • How to set the Initial path in the FILE name field of a JFilechooser?

    as title
    thx...

    try this....
    File file =null;
    JFileChooser fileDemo=new JFileChooser();
    fileDemo.setCurrentDirectory(new File("e:\\test"));
    instead of "e:\\test" you can specify your path.

  • InfoPath Formula in the File Name Field

    I used the Now() formula as it shows like this:  "2015-04-14T09_35_26".    I want to shorten the field name to display it in the list as "DD/MM/YYYY".
    I was thinking of the String-length formula but not sure how to do it?
    Mike

    Hi Mike,
    According to you description, my understanding is that you want to change the formula Now() to display as “DD/MM/YYYY”.
    You could use the formula “concat(number(substring(now(), 6, 2)), "/", number(substring(now(), 9, 2)), "/", number(substring(now(), 1, 4)))” instead of Now().
    A similar post for your reference:
    http://www.infopathdev.com/forums/t/20434.aspx
    Best Regards,
    Dean Wang
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How to get the Output File Name as One of the Field Value From Payload

    Hi All,
    I want to get the Output file name as one of the Field value from payload.
    Example:
    Source XML
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_TEST xmlns:ns0="http://sample.com">
    - <Header>
      <NAME>Bopanna</NAME>
      </Header>
      </ns0:MT_TEST>
    I want to get the Output file name as " Bopanna.xml"
    Please suggest me on this.
    Regards
    Bopanna

    Hi,
    There are couple of links already available for this. Just for info see the below details,
    The Output file name could be used from the field value of payload. For this you need to use the UDF DynamicFile name with below code,
    //       Description: Function to create dynamic Filename
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File" , "FileName");
    conf.put(key,a);
    return "";
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File" , "FileName");
    conf.put(key,a);
    return "";
    With this udf map it with the MessageType as
    (File Name field from Payload) > DynamicFileConfiguration>MTReceiver
    Thanks
    Swarup

  • Excel 2010 missing default suggested file name in Save As dialog box

    I’m using Excel 2010 running on Windows 7 (32 bit).  When I open a certain file which produces the following message: "A file is in a different file format than its extension indicates", and then go to “Save As” (or “Save”) the
    file, the default suggested file name is missing (blank).  This didn't occur in previous versions of Excel. 
    In previous versions, Excel would automatically populate the original file name in to the File Name field.
      I have searched all over the net, looking for a way to change Excel so that it will once again populate the file name in this situation. 
    To reproduce:
    Create a new blank workbook
    save as type “Web Page”, (i.e. File name:  “Blank Example.html”)
    Close workbook
    In windows, rename file from .html to .xls  (i.e. rename “Blank Example.html” to “Blank Example.xls”)
    In Excel open renamed file (i.e. “Blank Example.xls”) and click “Yes” when prompted with the “A file is in a different file format than its extension indicates” message.
    Do a “Save As” and you will notice that the File Name is blank. In previous versions, this field would contain the current workbook file name
     (i.e. “Blank Example.xls”)
    Any help will be greatly appreciated.

    Hi Jaynet,
    In order to re-produce this, you need to answer "yes" to the rename file prompt and then continue with step 5 (above).
    The reason for this is not an exercise in futility - I assure you.  At my work and elsewhere, when web developers have created features to permit the end user to save web data in Excel format, often times the Excel files are saved locally in Excel's
    html format (but with the .xls
    extension). 
    (I actually prefer the .xls
    extension, because it is easier to just double-click the file to open in Excel, rather than to select the open-with and then select Excel. a file with the .html extension will default open in your default browser. Now, I could change my default program
    for the .html extension, but that would only solve a part of the problem and would not really address the bigger issue and that being that Microsoft changed a behavior in Excel and may not even be aware that it was a much used feature. )
    To continue, when I go to open the resulting Excel file, I am prompted with the message that the file type does not match the extension (which is fine and not bothersome to me).  It's at this point when I go to save the file that I get really annoyed.
    In previous versions of Excel, the default file name would be pre-filled with the current name of the file and the default file type would state that it is a Web html file.  I would just change the file type to Excel Workbook and hit enter to save.
    I would be prompted with "Are you sure you want to overwrite your existing file?" message and I would click "yes" and that would be that.
    However, in Excel 2010, because the default file name is blank, I then need to re-type the name into the field to save the file. 
    Any help is greatly appreciated.
    Thanks

  • Passing file name variable to the save as dialog

    Hi:
    I have an event listener that checks if the user has selected the file/"save as" menu and brings up another dialog window asking for some additional information about the client and job. I would like to pass a variable from this custom dialog to the file name field in the standard Save As dialog.
    Anybody have an idea how I can do this?
    I am using inDesign3 on Windows XP. I am using VB for the scripting.
    thanks!!
    Dan

    Hi: thanks for looking at it.
    Actually, I am not calling the save as in my script, the user is clicking on Save As and the event listener I have in the start up folder is picking that up. The event listener calls up a script that asks users to fill in a couple of fields about the specific job and once they do that and click ok, the default inDesign "save as" dialog is brought up. So that is my question -- how to pass the information from my dialog to the standard "save as" dialog (as the file name of the file).
    The event listener is of the beforeInvoke on the Save As... menu.
    Any idea?
    thanks!!
    Dan

Maybe you are looking for

  • Can no longer connect to Airport Express with upgrade to iTunes 10.1

    Since I upgraded to iTunes 10.1 I can no longer connect to my Airport Express (unknown error-15000). Another computer on my betwork running an older version of iTunes still works on the Airport Express. Any ideas? I have tried to uninstall and reinst

  • Added music not showing up in iTunes library

    I recently bought a cd online and I tried to add it to my library. I tried it like three times, the music isn't showing up there. When I go to the "recently added" playlist, I can see the music there and it's also on my iPod, but it's nowhere to be f

  • Reports - Data source for repeating frames

    Does anybody know if there is an alternative way to pass data to repeating frames than queries or ref cursors? For example can I use a PL/SQL table as source for a repeating frame?

  • Scheduler configuration in OBIEE-EBS inegrated environment

    Hi All, We currently have OBIEE 10g integrated with EBS. I am trying to configure a scheduler and the configuration is completed and I am able to save ibots. But when ibot is run, I am getting the below error. ++++ ThreadID: 1894 : 2013-02-26 11:36:2

  • Userexit / Correction ??

    Hi all, I am working out on Function exits. I created a project project and i maintained everything in SMOD/CMOD. From DOcumentation i read a staement like <b>When you create/change a project, you must create a correction. This correction contains on