@Override public void actionPerformed(ActionEvent arg0) { WrappedFileChooser fc = new WrappedFileChooser(this.getParent(), new BriefcaseFolderChooser(this.getParent())); // figure out the initial directory path... String candidateDir = txtBriefcaseLocation.getText(); File base = null; if (candidateDir == null || candidateDir.trim().length() == 0) { // nothing -- use default base = new File(BriefcasePreferences.getBriefcaseDirectoryProperty()); } else { // start with candidate parent and move up the tree until we have a valid directory. base = new File(candidateDir).getParentFile(); while (base != null && (!base.exists() || !base.isDirectory())) { base = base.getParentFile(); } } if (base != null) { fc.setSelectedFile(base); } int retVal = fc.showDialog(); if (retVal == JFileChooser.APPROVE_OPTION) { File parentFolder = fc.getSelectedFile(); if (parentFolder != null) { String briefcasePath = parentFolder.getAbsolutePath(); txtBriefcaseLocation.setText( briefcasePath + File.separator + FileSystemUtils.BRIEFCASE_DIR); } } }
public static File getBriefcaseFolder() { return new File(new File(BriefcasePreferences.getBriefcaseDirectoryProperty()), BRIEFCASE_DIR); }