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.java20
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java7
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java11
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java54
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java42
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java6
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java6
7 files changed, 74 insertions, 72 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 c98eea3..895faa6 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
@@ -27,15 +27,15 @@ public class DropdownListPanel extends JPanel {
*
* @param <T>
* The type of items in the dropdown list
- * @param itemType
+ * @param type
* The label of the type of items in the list
- * @param listModel
+ * @param model
* The model to put items into
* @param choices
* The items to choose from
*/
- public <T> DropdownListPanel(String itemType,
- DefaultListModel<T> listModel, IList<T> choices) {
+ public <T> DropdownListPanel(String type,
+ DefaultListModel<T> model, IList<T> choices) {
setLayout(new AutosizeLayout());
JPanel itemInputPanel = new JPanel();
@@ -47,23 +47,23 @@ public class DropdownListPanel extends JPanel {
JComboBox<T> addItemBox = new JComboBox<>();
choices.forEach(addItemBox::addItem);
- JButton addItemButton = new JButton("Add " + itemType);
+ JButton addItemButton = new JButton("Add " + type);
addItemPanel.add(addItemBox);
addItemPanel.add(addItemButton);
- JList<T> itemList = new JList<>(listModel);
+ JList<T> itemList = new JList<>(model);
itemList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- JButton removeItemButton = new JButton("Remove " + itemType);
+ JButton removeItemButton = new JButton("Remove " + type);
addItemButton.addActionListener((ev) -> {
- listModel.addElement(
+ model.addElement(
addItemBox.getItemAt(addItemBox.getSelectedIndex()));
});
removeItemButton.addActionListener((ev) -> {
- listModel.remove(itemList.getSelectedIndex());
+ model.remove(itemList.getSelectedIndex());
});
itemInputPanel.add(addItemPanel, BorderLayout.PAGE_START);
@@ -72,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/FormattedInputPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java
index 54970ec..a05c06e 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java
@@ -19,6 +19,7 @@ import bjc.utils.gui.layout.HLayout;
*/
public class FormattedInputPanel<InputVal> extends JPanel {
private static final long serialVersionUID = 5232016563558588031L;
+
private JFormattedTextField field;
/**
@@ -30,13 +31,13 @@ public class FormattedInputPanel<InputVal> extends JPanel {
* The length of this panel
* @param formatter
* The formatter to use for input
- * @param valueReciever
+ * @param reciever
* The action to call whenever the value changes
*/
@SuppressWarnings("unchecked")
public FormattedInputPanel(String label, int length,
AbstractFormatter formatter,
- Consumer<InputVal> valueReciever) {
+ Consumer<InputVal> reciever) {
setLayout(new HLayout(2));
JLabel lab = new JLabel(label);
@@ -47,7 +48,7 @@ public class FormattedInputPanel<InputVal> extends JPanel {
field.addPropertyChangeListener("value", (event) -> {
// This is safe, because InputVal should be the type of
// whatever object the formatter is returning
- valueReciever.accept((InputVal) field.getValue());
+ reciever.accept((InputVal) field.getValue());
});
add(lab);
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java
index 128dbfc..f7f2c26 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java
@@ -15,7 +15,8 @@ import bjc.utils.gui.layout.HLayout;
*/
public class HolderOutputPanel extends JPanel {
private static final long serialVersionUID = 166573313903782080L;
- private Timer updateTimer;
+
+ private Timer updater;
private JLabel value;
private int nDelay;
private IHolder<String> val;
@@ -40,7 +41,7 @@ public class HolderOutputPanel extends JPanel {
JLabel label = new JLabel(lab);
value = new JLabel("(stopped)");
- updateTimer = new Timer(nDelay, (event) -> {
+ updater = new Timer(nDelay, (event) -> {
value.setText(valueHolder.getValue());
});
@@ -56,7 +57,7 @@ public class HolderOutputPanel extends JPanel {
value.setText("(stopped)");
- updateTimer = new Timer(nDelay, (event) -> {
+ updater = new Timer(nDelay, (event) -> {
value.setText(val.getValue());
});
}
@@ -65,14 +66,14 @@ public class HolderOutputPanel extends JPanel {
* Start updating the contents of the field from the holder
*/
public void startUpdating() {
- updateTimer.start();
+ updater.start();
}
/**
* Stop updating the contents of the field from the holder
*/
public void stopUpdating() {
- updateTimer.stop();
+ updater.stop();
value.setText(value.getText() + " (stopped)");
}
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java
index 553d201..088be6c 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java
@@ -29,39 +29,39 @@ public class ListParameterPanel<E> extends JPanel {
/**
* Create a new panel using the specified actions for doing things
*
- * @param addAction
+ * @param add
* The action that provides items
- * @param editAction
+ * @param edit
* The action that edits items
- * @param removeAction
+ * @param remove
* The action that removes items
*/
- public ListParameterPanel(Supplier<E> addAction,
- Consumer<E> editAction, Consumer<E> removeAction) {
- this(addAction, editAction, removeAction, null);
+ public ListParameterPanel(Supplier<E> add,
+ Consumer<E> edit, Consumer<E> remove) {
+ this(add, edit, remove, null);
}
/**
* Create a new panel using the specified actions for doing things
*
- * @param addAction
+ * @param add
* The action that provides items
- * @param editAction
+ * @param edit
* The action that edits items
- * @param removeAction
+ * @param remove
* The action that removes items
- * @param defaultValues
+ * @param defaults
* The default values to put in the list
*/
- public ListParameterPanel(Supplier<E> addAction,
- Consumer<E> editAction, Consumer<E> removeAction,
- IList<E> defaultValues) {
+ public ListParameterPanel(Supplier<E> add,
+ Consumer<E> edit, Consumer<E> remove,
+ IList<E> defaults) {
setLayout(new VLayout(2));
JList<E> list;
- if (defaultValues != null) {
- list = SimpleJList.buildFromList(defaultValues.toIterable());
+ if (defaults != null) {
+ list = SimpleJList.buildFromList(defaults.toIterable());
} else {
list = new JList<>(new DefaultListModel<>());
}
@@ -72,15 +72,15 @@ public class ListParameterPanel<E> extends JPanel {
int numButtons = 0;
- if (addAction != null) {
+ if (add != null) {
numButtons++;
}
- if (editAction != null) {
+ if (edit != null) {
numButtons++;
}
- if (removeAction != null) {
+ if (remove != null) {
numButtons++;
}
@@ -88,46 +88,46 @@ public class ListParameterPanel<E> extends JPanel {
JButton addParam = null;
- if (addAction != null) {
+ if (add != null) {
addParam = new JButton("Add...");
addParam.addActionListener((event) -> {
DefaultListModel<
E> model = (DefaultListModel<E>) list.getModel();
- model.addElement(addAction.get());
+ model.addElement(add.get());
});
}
JButton editParam = null;
- if (editAction != null) {
+ if (edit != null) {
editParam = new JButton("Edit...");
editParam.addActionListener((event) -> {
- editAction.accept(list.getSelectedValue());
+ edit.accept(list.getSelectedValue());
});
}
JButton removeParam = null;
- if (removeAction != null) {
+ if (remove != null) {
removeParam = new JButton("Remove...");
removeParam.addActionListener((event) -> {
DefaultListModel<
E> model = (DefaultListModel<E>) list.getModel();
- removeAction.accept(model.remove(list.getSelectedIndex()));
+ remove.accept(model.remove(list.getSelectedIndex()));
});
}
- if (addAction != null) {
+ if (add != null) {
buttonPanel.add(addParam);
}
- if (editAction != null) {
+ if (edit != null) {
buttonPanel.add(editParam);
}
- if (removeAction != null) {
+ if (remove != null) {
buttonPanel.add(removeParam);
}
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 e034b48..48230dd 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
@@ -24,16 +24,16 @@ import bjc.utils.gui.layout.HLayout;
public class SimpleListPanel extends JPanel {
private static final long serialVersionUID = 2719963952350133541L;
- private static void addItem(DefaultListModel<String> listModel,
- Predicate<String> itemVerifier,
- Consumer<String> onVerificationFailure,
+ private static void addItem(DefaultListModel<String> model,
+ Predicate<String> verifier,
+ Consumer<String> onFailure,
JTextField addItemField) {
String potentialItem = addItemField.getText();
- if (itemVerifier == null || itemVerifier.test(potentialItem)) {
- listModel.addElement(potentialItem);
+ if (verifier == null || verifier.test(potentialItem)) {
+ model.addElement(potentialItem);
} else {
- onVerificationFailure.accept(potentialItem);
+ onFailure.accept(potentialItem);
}
addItemField.setText("");
@@ -42,19 +42,19 @@ public class SimpleListPanel extends JPanel {
/**
* Create a new list panel
*
- * @param itemType
+ * @param type
* The type of things in the list
- * @param listModel
+ * @param model
* The model to put items into
- * @param itemVerifier
+ * @param verifier
* The predicate to use to verify items
- * @param onVerificationFailure
+ * @param onFailure
* The function to call when an item doesn't verify
*/
- public SimpleListPanel(String itemType,
- DefaultListModel<String> listModel,
- Predicate<String> itemVerifier,
- Consumer<String> onVerificationFailure) {
+ public SimpleListPanel(String type,
+ DefaultListModel<String> model,
+ Predicate<String> verifier,
+ Consumer<String> onFailure) {
setLayout(new AutosizeLayout());
JPanel itemInputPanel = new JPanel();
@@ -64,30 +64,30 @@ public class SimpleListPanel extends JPanel {
addItemPanel.setLayout(new HLayout(2));
JTextField addItemField = new JTextField(255);
- JButton addItemButton = new JButton("Add " + itemType);
+ JButton addItemButton = new JButton("Add " + type);
addItemPanel.add(addItemField);
addItemPanel.add(addItemButton);
- JList<String> itemList = new JList<>(listModel);
+ JList<String> itemList = new JList<>(model);
itemList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane listScroller = new JScrollPane(itemList);
- JButton removeItemButton = new JButton("Remove " + itemType);
+ JButton removeItemButton = new JButton("Remove " + type);
addItemButton.addActionListener((ev) -> {
- addItem(listModel, itemVerifier, onVerificationFailure,
+ addItem(model, verifier, onFailure,
addItemField);
});
addItemField.addActionListener((ev) -> {
- addItem(listModel, itemVerifier, onVerificationFailure,
+ addItem(model, verifier, onFailure,
addItemField);
});
removeItemButton.addActionListener((ev) -> {
- listModel.remove(itemList.getSelectedIndex());
+ model.remove(itemList.getSelectedIndex());
});
itemInputPanel.add(addItemPanel, BorderLayout.PAGE_START);
@@ -96,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 7b138c5..bd39972 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
@@ -15,7 +15,7 @@ import javax.swing.SpinnerModel;
public class SimpleSpinnerPanel extends JPanel {
private static final long serialVersionUID = -4734279623645236868L;
- /**
+ /*
* The spinner being used
*/
public final JSpinner inputValue;
@@ -30,9 +30,9 @@ public class SimpleSpinnerPanel extends JPanel {
JLabel inputLabel = new JLabel(label);
- inputValue = new JSpinner(model);
+ input = new JSpinner(model);
add(inputLabel, BorderLayout.LINE_START);
- add(inputValue, BorderLayout.CENTER);
+ add(input, BorderLayout.CENTER);
}
}
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java
index 792db73..9de4d63 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java
@@ -157,11 +157,11 @@ public class SliderInputPanel extends JPanel {
if (slider.getValueIsAdjusting()) {
// Do nothing
} else {
- int sliderVal = slider.getValue();
+ int val = slider.getValue();
- field.setValue(sliderVal);
+ field.setValue(val);
- action.accept(sliderVal);
+ action.accept(val);
}
});