diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-02-21 15:42:14 -0500 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-02-21 15:42:14 -0500 |
| commit | c2089e5a3e604424c7cd00bbddcb03731ff5a0ea (patch) | |
| tree | 31854f794e47b8dc67ea10d6699368810ca78f55 /BJC-Utils2/src/main/java/bjc/utils/gui/awt | |
| parent | eb30c23bb03579bf839189ab0d2ad172d5b07766 (diff) | |
Added new control and some commenting
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gui/awt')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java | 37 | ||||
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java | 50 |
2 files changed, 76 insertions, 11 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java b/BJC-Utils2/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java index fb857eb..6f43ba9 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/awt/ExtensionFileFilter.java @@ -7,12 +7,37 @@ import java.util.List; import bjc.utils.funcdata.FunctionalList; +/** + * Filter a set of filenames by extension. + * + * Built for AWT + * + * @author ben + * + */ public class ExtensionFileFilter implements FilenameFilter { + /** + * The list of extensions to filter + */ private FunctionalList<String> extensions; /** - * Create a new filter only showing files with the specified extensions. - * @param exts The extensions to show in this filter. + * Create a new filter only showing files with the specified + * extensions. + * + * @param exts + * The extensions to show in this filter. + */ + public ExtensionFileFilter(List<String> exts) { + extensions = new FunctionalList<>(exts); + } + + /** + * Create a new filter only showing files with the specified + * extensions. + * + * @param exts + * The extensions to show in this filter. */ public ExtensionFileFilter(String... exts) { extensions = new FunctionalList<>(new ArrayList<>(exts.length)); @@ -22,14 +47,6 @@ public class ExtensionFileFilter implements FilenameFilter { } } - /** - * Create a new filter only showing files with the specified extensions. - * @param exts The extensions to show in this filter. - */ - public ExtensionFileFilter(List<String> exts) { - extensions = new FunctionalList<>(exts); - } - @Override public boolean accept(File dir, String name) { return extensions.anyMatch(name::endsWith); 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 1d14903..2e13949 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 @@ -7,7 +7,26 @@ 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 par + * The parent of the file picker + * @param title + * The title of the file picker + * @param extensions + * The extensions to accept as valid + * @return The file the user picked + */ public static File getOpenFile(Frame par, String title, String... extensions) { FileDialog fd = new FileDialog(par, title, FileDialog.LOAD); @@ -28,10 +47,30 @@ public class SimpleFileDialog { return fd.getFiles()[0]; } + /** + * Prompt the user to pick a file to open + * + * @param par + * 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); } - + + /** + * Prompt the user to pick a file to save + * + * @param par + * The parent of the file picker + * @param title + * The title of the file picker + * @param extensions + * The extensions to accept as valid + * @return The file the user picked + */ public static File getSaveFile(Frame par, String title, String... extensions) { FileDialog fd = new FileDialog(par, title, FileDialog.SAVE); @@ -52,6 +91,15 @@ public class SimpleFileDialog { return fd.getFiles()[0]; } + /** + * Prompt the user to pick a file to save + * + * @param par + * 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); } |
