summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/gui/panels
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gui/panels')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java24
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java13
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java20
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java13
4 files changed, 66 insertions, 4 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java
index 2231760..c98eea3 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/DropdownListPanel.java
@@ -13,10 +13,27 @@ import bjc.utils.funcdata.IList;
import bjc.utils.gui.layout.AutosizeLayout;
import bjc.utils.gui.layout.HLayout;
+/**
+ * A panel that allows you to select choices from a dropdown list
+ *
+ * @author ben
+ *
+ */
public class DropdownListPanel extends JPanel {
private static final long serialVersionUID = 2719963952350133541L;
- @SuppressWarnings("unchecked")
+ /**
+ * Create a new dropdown list panel
+ *
+ * @param <T>
+ * The type of items in the dropdown list
+ * @param itemType
+ * The label of the type of items in the list
+ * @param listModel
+ * The model to put items into
+ * @param choices
+ * The items to choose from
+ */
public <T> DropdownListPanel(String itemType,
DefaultListModel<T> listModel, IList<T> choices) {
setLayout(new AutosizeLayout());
@@ -41,7 +58,8 @@ public class DropdownListPanel extends JPanel {
JButton removeItemButton = new JButton("Remove " + itemType);
addItemButton.addActionListener((ev) -> {
- listModel.addElement((T) addItemBox.getSelectedItem());
+ listModel.addElement(
+ addItemBox.getItemAt(addItemBox.getSelectedIndex()));
});
removeItemButton.addActionListener((ev) -> {
@@ -54,4 +72,4 @@ public class DropdownListPanel extends JPanel {
add(itemInputPanel);
}
-}
+} \ No newline at end of file
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java
index fd981ec..eb900aa 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java
@@ -6,11 +6,24 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
+/**
+ * A simple component for text input
+ * @author ben
+ *
+ */
public class SimpleInputPanel extends JPanel {
private static final long serialVersionUID = -4734279623645236868L;
+ /**
+ * The text field containing the input value
+ */
public final JTextField inputValue;
+ /**
+ * Create a new input panel
+ * @param label The label for the field
+ * @param columns The number of columns of text input to take
+ */
public SimpleInputPanel(String label, int columns) {
setLayout(new BorderLayout());
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java
index 62aac0d..e034b48 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java
@@ -15,6 +15,12 @@ import javax.swing.ListSelectionModel;
import bjc.utils.gui.layout.AutosizeLayout;
import bjc.utils.gui.layout.HLayout;
+/**
+ * A simple list of strings
+ *
+ * @author ben
+ *
+ */
public class SimpleListPanel extends JPanel {
private static final long serialVersionUID = 2719963952350133541L;
@@ -33,6 +39,18 @@ public class SimpleListPanel extends JPanel {
addItemField.setText("");
}
+ /**
+ * Create a new list panel
+ *
+ * @param itemType
+ * The type of things in the list
+ * @param listModel
+ * The model to put items into
+ * @param itemVerifier
+ * The predicate to use to verify items
+ * @param onVerificationFailure
+ * The function to call when an item doesn't verify
+ */
public SimpleListPanel(String itemType,
DefaultListModel<String> listModel,
Predicate<String> itemVerifier,
@@ -78,4 +96,4 @@ public class SimpleListPanel extends JPanel {
add(itemInputPanel);
}
-}
+} \ No newline at end of file
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java
index 7bbf83e..7b138c5 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java
@@ -7,11 +7,24 @@ import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerModel;
+/**
+ * A simple spinner control
+ * @author ben
+ *
+ */
public class SimpleSpinnerPanel extends JPanel {
private static final long serialVersionUID = -4734279623645236868L;
+ /**
+ * The spinner being used
+ */
public final JSpinner inputValue;
+ /**
+ * Create a new spinner panel
+ * @param label The label for the spinner
+ * @param model The model to attach to the spinner
+ */
public SimpleSpinnerPanel(String label, SpinnerModel model) {
setLayout(new BorderLayout());