diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-04-10 16:40:33 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-04-10 16:40:33 -0400 |
| commit | 889fac2bdf993dc86f64a8893c0260fdcf848acb (patch) | |
| tree | 99ed08552efa86fdc5fdf4ddb8720d10e599fafe /BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java | |
| parent | 1656b02144446aeedebb3d1179e07ed99c01861c (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 | 50 |
1 files changed, 25 insertions, 25 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 47f76b8..77a4a59 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,12 +1,12 @@ 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 * @@ -25,7 +25,7 @@ public class SimpleFileDialog { * The title of the file picker * @return The file the user picked */ - public static File getOpenFile(Frame parent, String title) { + public static File getOpenFile(final Frame parent, final String title) { return getOpenFile(parent, title, (String[]) null); } @@ -40,21 +40,21 @@ public class SimpleFileDialog { * The extensions to accept as valid * @return The file the user picked */ - public static File getOpenFile(Frame parent, String title, String... extensions) { - if(parent == null) + public static File getOpenFile(final Frame parent, final String title, final String... extensions) { + 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); + final FileDialog chooser = new FileDialog(parent, title, FileDialog.LOAD); - if(extensions != null) { - FilenameFilter filter = new ExtensionFileFilter(extensions); + if (extensions != null) { + final 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); } @@ -73,22 +73,22 @@ public class SimpleFileDialog { * The extensions to accept as valid * @return The file the user picked */ - public static File[] getOpenFiles(Frame parent, String title, String... extensions) { - if(parent == null) + public static File[] getOpenFiles(final Frame parent, final String title, final String... extensions) { + 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); + final FileDialog chooser = new FileDialog(parent, title, FileDialog.LOAD); - if(extensions != null) { - FilenameFilter filter = new ExtensionFileFilter(extensions); + if (extensions != null) { + final FilenameFilter filter = new ExtensionFileFilter(extensions); chooser.setFilenameFilter(filter); } 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); } @@ -105,7 +105,7 @@ public class SimpleFileDialog { * The title of the file picker * @return The file the user picked */ - public static File getSaveFile(Frame parent, String title) { + public static File getSaveFile(final Frame parent, final String title) { return getSaveFile(parent, title, (String[]) null); } @@ -120,21 +120,21 @@ public class SimpleFileDialog { * The extensions to accept as valid * @return The file the user picked */ - public static File getSaveFile(Frame parent, String title, String... extensions) { - if(parent == null) + public static File getSaveFile(final Frame parent, final String title, final String... extensions) { + 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); + final FileDialog chooser = new FileDialog(parent, title, FileDialog.SAVE); - if(extensions != null) { - FilenameFilter filter = new ExtensionFileFilter(extensions); + if (extensions != null) { + final 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); } |
