summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleDialogs.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2016-02-21 15:42:14 -0500
committerbculkin2442 <bjculkin@mix.wvu.edu>2016-02-21 15:42:14 -0500
commitc2089e5a3e604424c7cd00bbddcb03731ff5a0ea (patch)
tree31854f794e47b8dc67ea10d6699368810ca78f55 /BJC-Utils2/src/main/java/bjc/utils/gui/SimpleDialogs.java
parenteb30c23bb03579bf839189ab0d2ad172d5b07766 (diff)
Added new control and some commenting
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gui/SimpleDialogs.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/SimpleDialogs.java92
1 files changed, 46 insertions, 46 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleDialogs.java b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleDialogs.java
index 85b9fa9..ea48977 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleDialogs.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleDialogs.java
@@ -49,6 +49,52 @@ public class SimpleDialogs {
}
/**
+ * Asks the user to pick an option from a series of choices.
+ *
+ * @param parent
+ * The parent frame for this dialog
+ * @param title
+ * The title of this dialog
+ * @param question
+ * The question being asked
+ * @param choices
+ * The available choices for the question
+ * @return The choice the user picked, or null if they didn't pick one
+ */
+ @SuppressWarnings("unchecked")
+ public static <E> E getChoice(Frame parent, String title,
+ String question, E... choices) {
+ JDialog jd = new JDialog(parent, title, true);
+ jd.setLayout(new VLayout(2));
+
+ JPanel questionPane = new JPanel();
+
+ JLabel questionText = new JLabel(question);
+ JComboBox<E> questionChoices = new JComboBox<>(choices);
+
+ questionPane.add(questionText);
+ questionPane.add(questionChoices);
+
+ JPanel buttonPane = new JPanel();
+
+ JButton okButton = new JButton("Ok");
+ okButton.addActionListener(e -> jd.dispose());
+ JButton cancelButton = new JButton("Cancel");
+ cancelButton.addActionListener(e -> jd.dispose());
+
+ buttonPane.add(cancelButton);
+ buttonPane.add(okButton);
+
+ jd.add(questionPane);
+ jd.add(buttonPane);
+
+ jd.pack();
+ jd.setVisible(true);
+
+ return (E) questionChoices.getSelectedItem();
+ }
+
+ /**
* Get a integer from the user
*
* @param parent
@@ -152,52 +198,6 @@ public class SimpleDialogs {
}
/**
- * Asks the user to pick an option from a series of choices.
- *
- * @param parent
- * The parent frame for this dialog
- * @param title
- * The title of this dialog
- * @param question
- * The question being asked
- * @param choices
- * The availible choices for the question
- * @return The choice the user picked, or null if they didn't pick one
- */
- @SuppressWarnings("unchecked")
- public static <E> E getChoice(Frame parent, String title,
- String question, E... choices) {
- JDialog jd = new JDialog(parent, title, true);
- jd.setLayout(new VLayout(2));
-
- JPanel questionPane = new JPanel();
-
- JLabel questionText = new JLabel(question);
- JComboBox<E> questionChoices = new JComboBox<>(choices);
-
- questionPane.add(questionText);
- questionPane.add(questionChoices);
-
- JPanel buttonPane = new JPanel();
-
- JButton okButton = new JButton("Ok");
- okButton.addActionListener(e -> jd.dispose());
- JButton cancelButton = new JButton("Cancel");
- cancelButton.addActionListener(e -> jd.dispose());
-
- buttonPane.add(cancelButton);
- buttonPane.add(okButton);
-
- jd.add(questionPane);
- jd.add(buttonPane);
-
- jd.pack();
- jd.setVisible(true);
-
- return (E) questionChoices.getSelectedItem();
- }
-
- /**
* Show a error message to the user
*
* @param parent