From 504ca816530efdff06bc202e0432ebd354aec304 Mon Sep 17 00:00:00 2001 From: EVE Date: Tue, 14 Mar 2017 12:07:14 -0400 Subject: Cleanup --- .../java/bjc/utils/gui/awt/SimpleFileDialog.java | 48 ++++++++++------------ 1 file changed, 21 insertions(+), 27 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java') 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); } -- cgit v1.2.3