diff options
Diffstat (limited to 'BJC-Utils2/src/main')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalFrame.java | 26 | ||||
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java | 39 |
2 files changed, 65 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalFrame.java b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalFrame.java new file mode 100644 index 0000000..61c6702 --- /dev/null +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalFrame.java @@ -0,0 +1,26 @@ +package bjc.utils.gui; + +import javax.swing.JInternalFrame; + +public class SimpleInternalFrame extends JInternalFrame { + private static final long serialVersionUID = -2966801321260716617L; + + public SimpleInternalFrame() { + super(); + } + + public SimpleInternalFrame(String title) { + super(title); + } + + protected void setupFrame() { + setSize(320, 240); + + setResizable(true); + + setClosable(true); + setMaximizable(true); + setIconifiable(true); + } + +}
\ No newline at end of file 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 4e887f4..79ba4be 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 @@ -68,6 +68,45 @@ public class SimpleFileDialog { } /** + * Prompt the user to pick a file to open + * + * @param parent + * 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[] getOpenFiles(Frame parent, String title, + 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"); + } + + FileDialog fileDialog = new FileDialog(parent, title, + FileDialog.LOAD); + + if (extensions != null) { + FilenameFilter filter = new ExtensionFileFilter(extensions); + fileDialog.setFilenameFilter(filter); + } + + fileDialog.setMultipleMode(true); + fileDialog.setVisible(true); + + while (fileDialog.getFile() == null) { + SimpleDialogs.showError(parent, "File I/O Error", + "Please choose a file to open."); + fileDialog.setVisible(true); + } + + return fileDialog.getFiles(); + } + + /** * Prompt the user to pick a file to save * * @param parent |
