diff options
| author | EVE <EVE@EVE-PC> | 2017-03-14 12:07:14 -0400 |
|---|---|---|
| committer | EVE <EVE@EVE-PC> | 2017-03-14 12:07:14 -0400 |
| commit | 504ca816530efdff06bc202e0432ebd354aec304 (patch) | |
| tree | 4836932fb81d1d625470502c78c94d202c9a7420 /BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java | |
| parent | 5c1163df17c46f7d3e15b6c7949c38843ec56146 (diff) | |
Cleanup
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 | 48 |
1 files changed, 21 insertions, 27 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 041a9a2..47f76b8 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 @@ -1,24 +1,24 @@ package bjc.utils.gui.awt; +import bjc.utils.gui.SimpleDialogs; + import java.awt.FileDialog; import java.awt.Frame; import java.io.File; import java.io.FilenameFilter; -import bjc.utils.gui.SimpleDialogs; - /** * A simple way to get the user to pick a file - * + * * Built for AWT. - * + * * @author ben * */ public class SimpleFileDialog { /** * Prompt the user to pick a file to open - * + * * @param parent * The parent of the file picker * @param title @@ -31,7 +31,7 @@ public class SimpleFileDialog { /** * Prompt the user to pick a file to open - * + * * @param parent * The parent of the file picker * @param title @@ -41,22 +41,20 @@ public class SimpleFileDialog { * @return The file the user picked */ public static File getOpenFile(Frame parent, String title, String... extensions) { - if (parent == null) { + if(parent == null) throw new NullPointerException("Parent must not be null"); - } else if (title == null) { - throw new NullPointerException("Title must not be null"); - } + else if(title == null) throw new NullPointerException("Title must not be null"); FileDialog chooser = new FileDialog(parent, title, FileDialog.LOAD); - if (extensions != null) { + if(extensions != null) { FilenameFilter filter = new ExtensionFileFilter(extensions); chooser.setFilenameFilter(filter); } chooser.setVisible(true); - while (chooser.getFile() == null) { + while(chooser.getFile() == null) { SimpleDialogs.showError(parent, "File I/O Error", "Please choose a file to open."); chooser.setVisible(true); } @@ -66,7 +64,7 @@ public class SimpleFileDialog { /** * Prompt the user to pick a file to open - * + * * @param parent * The parent of the file picker * @param title @@ -76,15 +74,13 @@ public class SimpleFileDialog { * @return The file the user picked */ public static File[] getOpenFiles(Frame parent, String title, String... extensions) { - if (parent == null) { + if(parent == null) throw new NullPointerException("Parent must not be null"); - } else if (title == null) { - throw new NullPointerException("Title must not be null"); - } + else if(title == null) throw new NullPointerException("Title must not be null"); FileDialog chooser = new FileDialog(parent, title, FileDialog.LOAD); - if (extensions != null) { + if(extensions != null) { FilenameFilter filter = new ExtensionFileFilter(extensions); chooser.setFilenameFilter(filter); } @@ -92,7 +88,7 @@ public class SimpleFileDialog { chooser.setMultipleMode(true); chooser.setVisible(true); - while (chooser.getFile() == null) { + while(chooser.getFile() == null) { SimpleDialogs.showError(parent, "File I/O Error", "Please choose a file to open."); chooser.setVisible(true); } @@ -102,7 +98,7 @@ public class SimpleFileDialog { /** * Prompt the user to pick a file to save - * + * * @param parent * The parent of the file picker * @param title @@ -115,7 +111,7 @@ public class SimpleFileDialog { /** * Prompt the user to pick a file to save - * + * * @param parent * The parent of the file picker * @param title @@ -125,22 +121,20 @@ public class SimpleFileDialog { * @return The file the user picked */ public static File getSaveFile(Frame parent, String title, String... extensions) { - if (parent == null) { + if(parent == null) throw new NullPointerException("Parent must not be null"); - } else if (title == null) { - throw new NullPointerException("Title must not be null"); - } + else if(title == null) throw new NullPointerException("Title must not be null"); FileDialog chooser = new FileDialog(parent, title, FileDialog.SAVE); - if (extensions != null) { + if(extensions != null) { FilenameFilter filter = new ExtensionFileFilter(extensions); chooser.setFilenameFilter(filter); } chooser.setVisible(true); - while (chooser.getFile() == null) { + while(chooser.getFile() == null) { SimpleDialogs.showError(parent, "File I/O Error", "Please choose a file to save to."); chooser.setVisible(true); } |
