diff options
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java b/BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java index c12119f..a8df3b9 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java @@ -19,20 +19,20 @@ public class SimpleFileDialog { /** * Prompt the user to pick a file to open * - * @param par + * @param parent * The parent of the file picker * @param title * The title of the file picker * @return The file the user picked */ - public static File getOpenFile(Frame par, String title) { - return getOpenFile(par, title, (String[]) null); + public static File getOpenFile(Frame parent, String title) { + return getOpenFile(parent, title, (String[]) null); } /** * Prompt the user to pick a file to open * - * @param par + * @param parent * The parent of the file picker * @param title * The title of the file picker @@ -40,43 +40,44 @@ public class SimpleFileDialog { * The extensions to accept as valid * @return The file the user picked */ - public static File getOpenFile(Frame par, String title, + public static File getOpenFile(Frame parent, String title, String... extensions) { - FileDialog fd = new FileDialog(par, title, FileDialog.LOAD); + FileDialog fileDialog = + new FileDialog(parent, title, FileDialog.LOAD); if (extensions != null) { FilenameFilter filter = new ExtensionFileFilter(extensions); - fd.setFilenameFilter(filter); + fileDialog.setFilenameFilter(filter); } - fd.setVisible(true); + fileDialog.setVisible(true); - while (fd.getFile() == null) { - SimpleDialogs.showError(par, "File I/O Error", + while (fileDialog.getFile() == null) { + SimpleDialogs.showError(parent, "File I/O Error", "Please choose a file to open."); - fd.setVisible(true); + fileDialog.setVisible(true); } - return fd.getFiles()[0]; + return fileDialog.getFiles()[0]; } /** * Prompt the user to pick a file to save * - * @param par + * @param parent * The parent of the file picker * @param title * The title of the file picker * @return The file the user picked */ - public static File getSaveFile(Frame par, String title) { - return getSaveFile(par, title, (String[]) null); + public static File getSaveFile(Frame parent, String title) { + return getSaveFile(parent, title, (String[]) null); } /** * Prompt the user to pick a file to save * - * @param par + * @param parent * The parent of the file picker * @param title * The title of the file picker @@ -84,23 +85,24 @@ public class SimpleFileDialog { * The extensions to accept as valid * @return The file the user picked */ - public static File getSaveFile(Frame par, String title, + public static File getSaveFile(Frame parent, String title, String... extensions) { - FileDialog fd = new FileDialog(par, title, FileDialog.SAVE); + FileDialog fileDialog = + new FileDialog(parent, title, FileDialog.SAVE); if (extensions != null) { FilenameFilter filter = new ExtensionFileFilter(extensions); - fd.setFilenameFilter(filter); + fileDialog.setFilenameFilter(filter); } - fd.setVisible(true); + fileDialog.setVisible(true); - while (fd.getFile() == null) { - SimpleDialogs.showError(par, "File I/O Error", + while (fileDialog.getFile() == null) { + SimpleDialogs.showError(parent, "File I/O Error", "Please choose a file to save to."); - fd.setVisible(true); + fileDialog.setVisible(true); } - return fd.getFiles()[0]; + return fileDialog.getFiles()[0]; } } |
