首页 > 代码库 > 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);