Skip to content
Advertisement

JFileChooser change default directory in Windows

I want to change the default directory of my JFileChooser to “My Music” on Windows. This directory is C:UsersFreMusic on my account because my username is Fre

The default is set on C:UsersFreDocuments (depends on OS i think). How can I change this?

Advertisement

Answer

You can use the API method setCurrentDirectory when initializing your JFileChooser objects:

JavaScript

Sample usage might be like:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement