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?
Re: JFileChooser - File name field(label)
:confused: 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
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
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