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.java12
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/FormattedInputPanel.java10
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/HolderOutputPanel.java18
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/ListParameterPanel.java36
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleInputPanel.java6
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleListPanel.java12
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/SimpleSpinnerPanel.java4
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java47
8 files changed, 71 insertions, 74 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 f2d7f7b..6e6be02 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
@@ -1,5 +1,9 @@
package bjc.utils.gui.panels;
+import bjc.utils.funcdata.IList;
+import bjc.utils.gui.layout.AutosizeLayout;
+import bjc.utils.gui.layout.HLayout;
+
import java.awt.BorderLayout;
import javax.swing.DefaultListModel;
@@ -9,13 +13,9 @@ import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
-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
*
*/
@@ -24,7 +24,7 @@ public class DropdownListPanel extends JPanel {
/**
* Create a new dropdown list panel
- *
+ *
* @param <T>
* The type of items in the dropdown list
* @param type
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 ae62a43..877f308 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
@@ -1,5 +1,7 @@
package bjc.utils.gui.panels;
+import bjc.utils.gui.layout.HLayout;
+
import java.util.function.Consumer;
import javax.swing.JFormattedTextField;
@@ -7,11 +9,9 @@ import javax.swing.JFormattedTextField.AbstractFormatter;
import javax.swing.JLabel;
import javax.swing.JPanel;
-import bjc.utils.gui.layout.HLayout;
-
/**
* A simple panel allowing for input of a single formatted value
- *
+ *
* @author ben
*
* @param <InputVal>
@@ -24,7 +24,7 @@ public class FormattedInputPanel<InputVal> extends JPanel {
/**
* Create a new formatted input panel
- *
+ *
* @param label
* The label for this panel
* @param length
@@ -55,7 +55,7 @@ public class FormattedInputPanel<InputVal> extends JPanel {
/**
* Reset the value in this panel to a specified value
- *
+ *
* @param value
* The value to set the panel to
*/
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 b6fc807..054eb38 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
@@ -1,29 +1,29 @@
package bjc.utils.gui.panels;
+import bjc.utils.data.IHolder;
+import bjc.utils.gui.layout.HLayout;
+
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.Timer;
-import bjc.utils.data.IHolder;
-import bjc.utils.gui.layout.HLayout;
-
/**
* A panel that outputs a value bound to a {@link IHolder}
- *
+ *
* @author ben
*
*/
public class HolderOutputPanel extends JPanel {
private static final long serialVersionUID = 166573313903782080L;
- private Timer updater;
- private JLabel value;
- private int nDelay;
- private IHolder<String> val;
+ private Timer updater;
+ private JLabel value;
+ private int nDelay;
+ private IHolder<String> val;
/**
* Create a new display panel, backed by a holder
- *
+ *
* @param lab
* The label to attach to this field
* @param valueHolder
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 29ede89..8f68571 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
@@ -1,5 +1,10 @@
package bjc.utils.gui.panels;
+import bjc.utils.funcdata.IList;
+import bjc.utils.gui.SimpleJList;
+import bjc.utils.gui.layout.HLayout;
+import bjc.utils.gui.layout.VLayout;
+
import java.util.function.Consumer;
import java.util.function.Supplier;
@@ -9,14 +14,9 @@ import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
-import bjc.utils.funcdata.IList;
-import bjc.utils.gui.SimpleJList;
-import bjc.utils.gui.layout.HLayout;
-import bjc.utils.gui.layout.VLayout;
-
/**
* A panel that has a list of objects and ways of manipulating that list
- *
+ *
* @author ben
*
* @param <E>
@@ -28,7 +28,7 @@ public class ListParameterPanel<E> extends JPanel {
/**
* Create a new panel using the specified actions for doing things
- *
+ *
* @param add
* The action that provides items
* @param edit
@@ -42,7 +42,7 @@ public class ListParameterPanel<E> extends JPanel {
/**
* Create a new panel using the specified actions for doing things
- *
+ *
* @param add
* The action that provides items
* @param edit
@@ -57,7 +57,7 @@ public class ListParameterPanel<E> extends JPanel {
JList<E> list;
- if (defaults != null) {
+ if(defaults != null) {
list = SimpleJList.buildFromList(defaults.toIterable());
} else {
list = new JList<>(new DefaultListModel<>());
@@ -69,15 +69,15 @@ public class ListParameterPanel<E> extends JPanel {
int numButtons = 0;
- if (add != null) {
+ if(add != null) {
numButtons++;
}
- if (edit != null) {
+ if(edit != null) {
numButtons++;
}
- if (remove != null) {
+ if(remove != null) {
numButtons++;
}
@@ -85,7 +85,7 @@ public class ListParameterPanel<E> extends JPanel {
JButton addParam = null;
- if (add != null) {
+ if(add != null) {
addParam = new JButton("Add...");
addParam.addActionListener((event) -> {
DefaultListModel<E> model = (DefaultListModel<E>) list.getModel();
@@ -96,7 +96,7 @@ public class ListParameterPanel<E> extends JPanel {
JButton editParam = null;
- if (edit != null) {
+ if(edit != null) {
editParam = new JButton("Edit...");
editParam.addActionListener((event) -> {
edit.accept(list.getSelectedValue());
@@ -105,7 +105,7 @@ public class ListParameterPanel<E> extends JPanel {
JButton removeParam = null;
- if (remove != null) {
+ if(remove != null) {
removeParam = new JButton("Remove...");
removeParam.addActionListener((event) -> {
DefaultListModel<E> model = (DefaultListModel<E>) list.getModel();
@@ -114,15 +114,15 @@ public class ListParameterPanel<E> extends JPanel {
});
}
- if (add != null) {
+ if(add != null) {
buttonPanel.add(addParam);
}
- if (edit != null) {
+ if(edit != null) {
buttonPanel.add(editParam);
}
- if (remove != null) {
+ if(remove != null) {
buttonPanel.add(removeParam);
}
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 b90e25c..d0881c5 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
@@ -8,7 +8,7 @@ import javax.swing.JTextField;
/**
* A simple component for text input
- *
+ *
* @author ben
*
*/
@@ -22,7 +22,7 @@ public class SimpleInputPanel extends JPanel {
/**
* Create a new input panel
- *
+ *
* @param label
* The label for the field
* @param columns
@@ -33,7 +33,7 @@ public class SimpleInputPanel extends JPanel {
JLabel inputLabel = new JLabel(label);
- if (columns < 1) {
+ if(columns < 1) {
inputValue = new JTextField();
} else {
inputValue = new JTextField(columns);
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 11b209f..b4fcfe1 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
@@ -1,5 +1,8 @@
package bjc.utils.gui.panels;
+import bjc.utils.gui.layout.AutosizeLayout;
+import bjc.utils.gui.layout.HLayout;
+
import java.awt.BorderLayout;
import java.util.function.Consumer;
import java.util.function.Predicate;
@@ -12,12 +15,9 @@ import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
-import bjc.utils.gui.layout.AutosizeLayout;
-import bjc.utils.gui.layout.HLayout;
-
/**
* A simple list of strings
- *
+ *
* @author ben
*
*/
@@ -28,7 +28,7 @@ public class SimpleListPanel extends JPanel {
Consumer<String> onFailure, JTextField addItemField) {
String potentialItem = addItemField.getText();
- if (verifier == null || verifier.test(potentialItem)) {
+ if(verifier == null || verifier.test(potentialItem)) {
model.addElement(potentialItem);
} else {
onFailure.accept(potentialItem);
@@ -39,7 +39,7 @@ public class SimpleListPanel extends JPanel {
/**
* Create a new list panel
- *
+ *
* @param type
* The type of things in the list
* @param model
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 e9e94d5..a573bea 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
@@ -9,7 +9,7 @@ import javax.swing.SpinnerModel;
/**
* A simple spinner control
- *
+ *
* @author ben
*
*/
@@ -23,7 +23,7 @@ public class SimpleSpinnerPanel extends JPanel {
/**
* Create a new spinner panel
- *
+ *
* @param label
* The label for the spinner
* @param model
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 53bff32..71eaf33 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
@@ -1,5 +1,7 @@
package bjc.utils.gui.panels;
+import bjc.utils.gui.layout.HLayout;
+
import java.text.ParseException;
import java.util.function.Consumer;
@@ -8,12 +10,10 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
-import bjc.utils.gui.layout.HLayout;
-
/**
* A simple input panel for a slider-controlled value and a manual-input field
* for setting the slider
- *
+ *
* @author ben
*
*/
@@ -21,8 +21,8 @@ public class SliderInputPanel extends JPanel {
private final class NumberFormatter extends JFormattedTextField.AbstractFormatter {
private static final long serialVersionUID = -4448291795913908270L;
- private int minValue;
- private int maxValue;
+ private int minValue;
+ private int maxValue;
private int initValue;
@@ -38,14 +38,13 @@ public class SliderInputPanel extends JPanel {
try {
int val = Integer.parseInt(text);
- if (val < minValue) {
+ if(val < minValue)
throw new ParseException("Value must be greater than " + minValue, 0);
- } else if (val > maxValue) {
+ else if(val > maxValue)
throw new ParseException("Value must be smaller than " + maxValue, 0);
- } else {
+ else
return val;
- }
- } catch (NumberFormatException nfex) {
+ } catch(NumberFormatException nfex) {
ParseException pex = new ParseException("Value must be a valid integer", 0);
pex.initCause(nfex);
@@ -56,9 +55,7 @@ public class SliderInputPanel extends JPanel {
@Override
public String valueToString(Object value) throws ParseException {
- if (value == null) {
- return Integer.toString(initValue);
- }
+ if(value == null) return Integer.toString(initValue);
return Integer.toString((Integer) value);
}
@@ -66,7 +63,7 @@ public class SliderInputPanel extends JPanel {
/**
* Represents the settings for a slider
- *
+ *
* @author ben
*
*/
@@ -74,11 +71,11 @@ public class SliderInputPanel extends JPanel {
/**
* The minimum value of the slider
*/
- public final int minValue;
+ public final int minValue;
/**
* The maximum value of the slider
*/
- public final int maxValue;
+ public final int maxValue;
/**
* The initial value of the slider
@@ -88,7 +85,7 @@ public class SliderInputPanel extends JPanel {
/**
* Create a new slider settings, with the initial value in the
* middle
- *
+ *
* @param min
* The minimum value of the slider
* @param max
@@ -100,7 +97,7 @@ public class SliderInputPanel extends JPanel {
/**
* Create a new set of slider sttings
- *
+ *
* @param min
* The minimum slider value
* @param max
@@ -116,13 +113,13 @@ public class SliderInputPanel extends JPanel {
}
}
- private static final long serialVersionUID = 2956394160569961404L;
- private JSlider slider;
- private JFormattedTextField field;
+ private static final long serialVersionUID = 2956394160569961404L;
+ private JSlider slider;
+ private JFormattedTextField field;
/**
* Create a new slider input panel
- *
+ *
* @param lab
* The label for the field
* @param settings
@@ -149,7 +146,7 @@ public class SliderInputPanel extends JPanel {
slider.setPaintLabels(true);
slider.addChangeListener((event) -> {
- if (slider.getValueIsAdjusting()) {
+ if(slider.getValueIsAdjusting()) {
// Do nothing
} else {
int val = slider.getValue();
@@ -165,7 +162,7 @@ public class SliderInputPanel extends JPanel {
field.addPropertyChangeListener("value", (event) -> {
Object value = field.getValue();
- if (value == null) {
+ if(value == null) {
// Do nothing
} else {
slider.setValue((Integer) value);
@@ -179,7 +176,7 @@ public class SliderInputPanel extends JPanel {
/**
* Reset the values in this panel to a specified value
- *
+ *
* @param value
* The value to reset the fields to
*/