How to set the default file name of swing Jfilechooser?

I want to set the default file name to untitled. In this Jfilechooser text box txt. Can I set it?

Solution

Use the following code:

JFileChooser fileChooser = new JFileChooser();
        File file = new File("C:/untitled.txt");
        fileChooser.setCurrentDirectory(file);

You must specify untitled Txt

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>