JFileChooser change default directory in Windows

前端 未结 7 1028
粉色の甜心
粉色の甜心 2021-02-12 16:27

I want to change the default directory of my JFileChooser to \"My Music\" on Windows. This directory is C:\\Users\\Fre\\Music on my account because my username is <

7条回答
  •  失恋的感觉
    2021-02-12 16:54

    Sorry for taking your time, Just found the answer myself:

    String userhome = System.getProperty("user.home");
    JFileChooser fc = new JFileChooser(userhome +"\\Music");
    

提交回复
热议问题