diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-03-31 11:43:21 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-03-31 11:43:21 -0400 |
| commit | 8a8b457c98e207d809a7616e73eb59bfe197a7a5 (patch) | |
| tree | 36fcbb7f10e92adbfb866fced7f27af1ef89f636 /BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java | |
| parent | 32b1b46fcc855fffe6b0dddd10442a9a4f1544d2 (diff) | |
More code maintenance
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]; } } |
