CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2009
    Posts
    6

    JFileChooser - File name field(label)

    Hi!

    My question is if there is a method to change the file name field to....hmm...lets say empty.
    So when I choose to open the save/open jfilechooser dialog I want the "file name" field to be empty.

    So far I haven't succeeded to find a method for it or reach the file name label.

    Any suggestions/tips?

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: JFileChooser - File name field(label)

    The file name field is empty by default - I just ran the code below, and in the dialog the file name field was empty:
    Code:
    JFileChooser fc = new JFileChooser();
    int returnVal = fc.showOpenDialog(frame);
    If this isn't what you mean, what do you mean? - and what do you mean by 'reach the file name label'?

    The hardest part of the software task is arriving at a complete and consistent specification, and much of the essence of building a program is in fact the debugging of the specification...
    F. Brooks
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    Feb 2009
    Posts
    6

    Re: JFileChooser - File name field(label)

    Yep you are right, I should have explained a bit more.

    It's true that it is empty if you open the open/save filechooser first time....but let say if you save a file or open a file and then press open/save filechooser then it's not empty by default. The name on the file name filed is the file's name u've opened or saved.

    With File name label I mean the file name field where you write the file's name you want to save/open

  4. #4
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: JFileChooser - File name field(label)

    If you just want to clear the file name field the next time the FileChooser dialog is displayed, there are two choices - you can either create a new FlieChooser, or you can reuse the previous FileChooser and set the selected file to a file with no name, e.g:
    Code:
    final JFileChooser fc = new JFileChooser();
    int returnVal = fc.showOpenDialog(component);
    ...
    // clear file name for next selection
    fc.setSelectedFile(new File(""));
    returnVal = fc.showOpenDialog(component);
    Simplicity is the ultimate sophistication...
    L. Da Vinci
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured