其他分享
首页 > 其他分享> > JFileChooser记住上次选择的路径

JFileChooser记住上次选择的路径

作者:互联网

String saveFolder = "C:\\";
Preferences pref = Preferences.userRoot().node(
this.getClass().getName());
String lastPath = pref.get("lastPath", "");
JFileChooser fc = null;
if (!lastPath.equals("")) {
    fc = new JFileChooser(lastPath);
} else{
    fc = new JFileChooser(saveFolder);
}
saveFolder = fc.getSelectedFile().getPath();
pref.put("lastPath",saveFolder);

  

标签:pref,Preferences,路径,上次,fc,lastPath,saveFolder,JFileChooser
来源: https://www.cnblogs.com/wwssgg/p/15626157.html