| 1 4 package net.sf.launch4j.formimpl; 5 6 import java.io.File ; 7 import java.util.prefs.Preferences ; 8 9 import javax.swing.JFileChooser ; 10 11 14 public class FileChooser extends JFileChooser { 15 private final Preferences _prefs; 16 private final String _key; 17 18 public FileChooser(Class clazz) { 19 _prefs = Preferences.userNodeForPackage(clazz); 20 _key = "currentDir-" 21 + clazz.getName().substring(clazz.getName().lastIndexOf('.') + 1); 22 String path = _prefs.get(_key, null); 23 if (path != null) { 24 setCurrentDirectory(new File (path)); 25 } 26 } 27 28 public void approveSelection() { 29 _prefs.put(_key, getCurrentDirectory().getPath()); 30 super.approveSelection(); 31 } 32 } 33 | Popular Tags |