Hey!

My problem is that I can't modify the "File name" label / text field programatically where you write the file name of your file in the JFileChooser.

If I want to have "Write your file" written in the file name (by default) field how would I manage to do that?
I can't find a method that let's me modify that field/text field....I hope u understand and can help me with that problem.

I haven't used FileChooser much, but have you tried these methods:

setApproveButtonText(String approveButtonText)
Sets the text used in the ApproveButton in the FileChooserUI.

showDialog(Component parent, String approveButtonText)
Pops a custom file chooser dialog with a custom approve button.

Hey!

My problem is that I can't modify the "File name" label / text field programatically where you write the file name of your file in the JFileChooser.

If I want to have "Write your file" written in the file name (by default) field how would I manage to do that?
I can't find a method that let's me modify that field/text field....I hope u understand and can help me with that problem.

Question is unclear you better to elaborate more on it and/or support it with some screen shot.

Here a pic.

As u can see there is a Label named "File name" and what I want to do is to change the text field to the right of that label (programmatically ofc) to something.

I'm not sure if that is possible to do it directly on JFileChooser. Maybe somebody else would know more.
Option 2 would be create custom JFileChooser, see some examples here

That is the currently selected file, so you could do this

JFileChooser chooser = new JFileChooser();
chooser.setSelectedFile(new File("Write your file name here"));

Personally, I don't see why you would want to, but that will do it.

(And there is no one named "u" here. Leave the lazy chat speak at the door)

That is the currently selected file, so you could do this

JFileChooser chooser = new JFileChooser();
chooser.setSelectedFile(new File("Write your file name here"));

Personally, I don't see why you would want to, but that will do it.

(And there is no one named "u" here. Leave the lazy chat speak at the door)

Thanks!

Well I'm creating a drawing GUI application, and when you save the project, the file name field is empty but next time you do a "Save as..." the file name field is filled with "filename" without the extendsion (.xxx).

So the problem is that I couldn't add the extension (.xxx) of the file name so it would recognize it as the same file so if you want to do a "Save as..." it will appear "Do you want to overwrite the existing file?" dialog box.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.