* @return the selected path. Returns null if the user did not activate the approve option (closed the window or
* clicked "Cancel")
*/
public static String chooseFolder(String startingPath, Component parent, String title, Dimension dimension) {
try {
JFolderChooser chooser = new JFolderChooser();
chooser.setPreferredSize(dimension);
File outputFile = new File(startingPath);
if (outputFile.exists()) {
chooser.setCurrentDirectory(outputFile);
}
chooser.setTitle(title);
int choice = chooser.showOpenDialog(parent);
if (choice == JFolderChooser.APPROVE_OPTION) {
return chooser.getSelectedFile().getPath();
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "There has been an error:" + StringHelper.newline + e);
}
return null;