if(lastDir == null)
lastDir = new File(".");
if(OsIdent.checkOStype() == OsIdent.OS_MACOSX)
{
FileDialog chooser = new FileDialog(WindowUtils.findParentFrame(c), title);
System.setProperty("apple.awt.fileDialogForDirectories", "true");
chooser.setDirectory(lastDir.getAbsolutePath());
chooser.setMode(FileDialog.LOAD);
chooser.setVisible(true);
System.setProperty("apple.awt.fileDialogForDirectories", "false");
if(chooser.getFile() != null)
{
String folderName = chooser.getDirectory();
folderName += chooser.getFile();
return new File(folderName);
}
}
else
{
JFileChooser chooser = new JFileChooser(lastDir)
{
@Override
protected JDialog createDialog(Component parent)
throws HeadlessException
{
JDialog dlg = super.createDialog(parent);
WindowUtils.fitAndCenterInScreen(dlg, 0.5f, 0.5f);
return dlg;
}
};
chooser.setDialogTitle(title);
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = chooser.showDialog(c, approveButtonText);
if(returnVal == JFileChooser.APPROVE_OPTION)
return chooser.getSelectedFile();
}
return null;
}