* fix potential issues with previously accessed folders not being available anymore

This commit is contained in:
Reinhard Pointner 2014-12-29 11:47:26 +00:00
parent 52a7ba93cc
commit df74ec5e4c
1 changed files with 5 additions and 5 deletions

View File

@ -105,9 +105,9 @@ public class UserFiles {
chooser.setFileSelectionMode(folderMode && filter == null ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_AND_DIRECTORIES);
if (defaultFile != null) {
if (defaultFile.exists()) {
if (defaultFile.isFile()) {
chooser.setSelectedFile(defaultFile);
} else if (defaultFile.getParentFile().exists()) {
} else if (defaultFile.getParentFile() != null && defaultFile.getParentFile().isDirectory()) {
chooser.setCurrentDirectory(defaultFile.getParentFile());
}
}
@ -171,7 +171,7 @@ public class UserFiles {
fileDialog.setTitle(title);
fileDialog.setMultipleMode(false);
if (defaultFile != null) {
if (defaultFile.getParentFile() != null) {
if (defaultFile.getParentFile() != null && defaultFile.getParentFile().isDirectory()) {
fileDialog.setDirectory(defaultFile.getParentFile().getPath());
}
fileDialog.setFile(defaultFile.getName());
@ -248,7 +248,7 @@ public class UserFiles {
if (folderMode) {
javafx.stage.DirectoryChooser directoryChooser = new javafx.stage.DirectoryChooser();
directoryChooser.setTitle(title);
if (defaultFile != null) {
if (defaultFile != null && defaultFile.isDirectory()) {
directoryChooser.setInitialDirectory(defaultFile);
}
@ -301,7 +301,7 @@ public class UserFiles {
fileChooser.setTitle(title);
if (defaultFile != null) {
if (defaultFile.getParentFile() != null) {
if (defaultFile.getParentFile() != null && defaultFile.getParentFile().isDirectory()) {
fileChooser.setInitialDirectory(defaultFile.getParentFile());
}
fileChooser.setInitialFileName(defaultFile.getName());