summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/gui
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2017-02-09 11:50:31 -0500
committerbculkin2442 <bjculkin@mix.wvu.edu>2017-02-09 11:50:31 -0500
commitd2af58b0f68ebfbba2be7e7679efec6c8c0af12f (patch)
tree2b16fbf014db350126e8c1b5f081312276f85f62 /BJC-Utils2/src/main/java/bjc/utils/gui
parent187e1815488e3c1ed22e7592f304e632cffefb82 (diff)
Update
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gui')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/SimpleDialogs.java51
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/SimpleFileChooser.java8
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java39
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/SimpleJList.java16
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/TextAreaOutputStream.java6
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/awt/SimpleFileDialog.java38
-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
13 files changed, 154 insertions, 150 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 77e518e..68c4962 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleDialogs.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleDialogs.java
@@ -70,7 +70,6 @@ public class SimpleDialogs {
@SuppressWarnings("unchecked")
public static <E> E getChoice(Frame parent, String title,
String question, E... choices) {
-
if (parent == null) {
throw new NullPointerException("Parent must not be null");
} else if (title == null) {
@@ -79,8 +78,8 @@ public class SimpleDialogs {
throw new NullPointerException("Question must not be null");
}
- JDialog mainDialog = new JDialog(parent, title, true);
- mainDialog.setLayout(new VLayout(2));
+ JDialog chooser = new JDialog(parent, title, true);
+ chooser.setLayout(new VLayout(2));
JPanel questionPane = new JPanel();
@@ -95,17 +94,17 @@ public class SimpleDialogs {
JButton okButton = new JButton("Ok");
JButton cancelButton = new JButton("Cancel");
- okButton.addActionListener((event) -> mainDialog.dispose());
- cancelButton.addActionListener((event) -> mainDialog.dispose());
+ okButton.addActionListener((event) -> chooser.dispose());
+ cancelButton.addActionListener((event) -> chooser.dispose());
buttonPane.add(cancelButton);
buttonPane.add(okButton);
- mainDialog.add(questionPane);
- mainDialog.add(buttonPane);
+ chooser.add(questionPane);
+ chooser.add(buttonPane);
- mainDialog.pack();
- mainDialog.setVisible(true);
+ chooser.pack();
+ chooser.setVisible(true);
return (E) questionChoices.getSelectedItem();
}
@@ -172,30 +171,30 @@ public class SimpleDialogs {
* The title for dialogs.
* @param prompt
* The prompt to tell the user what to enter.
- * @param inputValidator
+ * @param validator
* A predicate to determine if a input is valid.
- * @param inputTransformer
+ * @param transformer
* The function to transform the string into a value.
* @return The value parsed from a string.
*/
public static <E> E getValue(Component parent, String title,
- String prompt, Predicate<String> inputValidator,
- Function<String, E> inputTransformer) {
- if (inputValidator == null) {
+ String prompt, Predicate<String> validator,
+ Function<String, E> transformer) {
+ if (validator == null) {
throw new NullPointerException("Validator must not be null");
- } else if (inputTransformer == null) {
+ } else if (transformer == null) {
throw new NullPointerException("Transformer must not be null");
}
- String inputString = getString(parent, title, prompt);
+ String input = getString(parent, title, prompt);
- while (!inputValidator.test(inputString)) {
+ while (!validator.test(input)) {
showError(parent, "I/O Error", "Please enter a valid value");
- inputString = getString(parent, title, prompt);
+ input = getString(parent, title, prompt);
}
- return inputTransformer.apply(inputString);
+ return transformer.apply(input);
}
/**
@@ -235,10 +234,10 @@ public class SimpleDialogs {
throw new NullPointerException("Question must not be null");
}
- int dialogResult = JOptionPane.showConfirmDialog(parent, question,
+ int result = JOptionPane.showConfirmDialog(parent, question,
title, JOptionPane.YES_NO_OPTION);
- return (dialogResult == JOptionPane.YES_OPTION ? true : false);
+ return (result == JOptionPane.YES_OPTION ? true : false);
}
/**
@@ -248,21 +247,21 @@ public class SimpleDialogs {
* The parent component for dialogs.
* @param title
* The title for dialogs.
- * @param errorMessage
+ * @param message
* The error to show the user.
*/
public static void showError(Component parent, String title,
- String errorMessage) {
+ String message) {
if (parent == null) {
throw new NullPointerException("Parent must not be null");
} else if (title == null) {
throw new NullPointerException("Title must not be null");
- } else if (errorMessage == null) {
+ } else if (message == null) {
throw new NullPointerException(
"Error message must not be null");
}
- JOptionPane.showMessageDialog(parent, errorMessage, title,
+ JOptionPane.showMessageDialog(parent, message, title,
JOptionPane.ERROR_MESSAGE);
}
@@ -289,4 +288,4 @@ public class SimpleDialogs {
JOptionPane.showMessageDialog(parent, title, message,
JOptionPane.INFORMATION_MESSAGE);
}
-} \ No newline at end of file
+}
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleFileChooser.java b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleFileChooser.java
index 010de5f..ae77e41 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleFileChooser.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleFileChooser.java
@@ -147,9 +147,9 @@ public class SimpleFileChooser {
"File chooser must not be null");
}
- int dialogResult = files.showSaveDialog(parent);
+ int result = files.showSaveDialog(parent);
- if (dialogResult != JFileChooser.APPROVE_OPTION) {
+ if (result != JFileChooser.APPROVE_OPTION) {
throw new FileNotChosenException();
}
}
@@ -163,9 +163,9 @@ public class SimpleFileChooser {
"File chooser must not be null");
}
- int dialogResult = files.showSaveDialog(parent);
+ int result = files.showSaveDialog(parent);
- if (dialogResult != JFileChooser.APPROVE_OPTION) {
+ if (result != JFileChooser.APPROVE_OPTION) {
throw new FileNotChosenException();
}
}
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java
index d38cadf..0152870 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java
@@ -7,8 +7,9 @@ import java.util.function.Predicate;
import javax.swing.JOptionPane;
/**
- * Utility class for getting simple input from the user. Modified to work
- * with JDesktopPanes
+ * Utility class for getting simple input from the user.
+ *
+ * Modified to work with JDesktopPanes
*
* @author ben
*
@@ -106,30 +107,30 @@ public class SimpleInternalDialogs {
* The title for dialogs.
* @param prompt
* The prompt to tell the user what to enter.
- * @param inputValidator
+ * @param validator
* A predicate to determine if a input is valid.
- * @param inputTransformer
+ * @param transformer
* The function to transform the string into a value.
* @return The value parsed from a string.
*/
public static <E> E getValue(Component parent, String title,
- String prompt, Predicate<String> inputValidator,
- Function<String, E> inputTransformer) {
- if (inputValidator == null) {
+ String prompt, Predicate<String> validator,
+ Function<String, E> transformer) {
+ if (validator == null) {
throw new NullPointerException("Validator must not be null");
- } else if (inputTransformer == null) {
+ } else if (transformer == null) {
throw new NullPointerException("Transformer must not be null");
}
- String inputString = getString(parent, title, prompt);
+ String strang = getString(parent, title, prompt);
- while (!inputValidator.test(inputString)) {
+ while (!validator.test(strang)) {
showError(parent, "I/O Error", "Please enter a valid value");
- inputString = getString(parent, title, prompt);
+ strang = getString(parent, title, prompt);
}
- return inputTransformer.apply(inputString);
+ return transformer.apply(strang);
}
/**
@@ -169,10 +170,10 @@ public class SimpleInternalDialogs {
throw new NullPointerException("Question must not be null");
}
- int dialogResult = JOptionPane.showInternalConfirmDialog(parent,
+ int result = JOptionPane.showInternalConfirmDialog(parent,
question, title, JOptionPane.YES_NO_OPTION);
- return (dialogResult == JOptionPane.YES_OPTION ? true : false);
+ return (result == JOptionPane.YES_OPTION ? true : false);
}
/**
@@ -182,21 +183,21 @@ public class SimpleInternalDialogs {
* The parent component for dialogs.
* @param title
* The title for dialogs.
- * @param errorMessage
+ * @param message
* The error to show the user.
*/
public static void showError(Component parent, String title,
- String errorMessage) {
+ String message) {
if (parent == null) {
throw new NullPointerException("Parent must not be null");
} else if (title == null) {
throw new NullPointerException("Title must not be null");
- } else if (errorMessage == null) {
+ } else if (message == null) {
throw new NullPointerException(
"Error message must not be null");
}
- JOptionPane.showInternalMessageDialog(parent, errorMessage, title,
+ JOptionPane.showInternalMessageDialog(parent, message, title,
JOptionPane.ERROR_MESSAGE);
}
@@ -223,4 +224,4 @@ public class SimpleInternalDialogs {
JOptionPane.showInternalMessageDialog(parent, title, message,
JOptionPane.INFORMATION_MESSAGE);
}
-} \ No newline at end of file
+}
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleJList.java b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleJList.java
index 4db5027..136c662 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleJList.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleJList.java
@@ -17,16 +17,16 @@ public class SimpleJList {
* @param <E>
* The type of data in the JList
*
- * @param listSource
+ * @param source
* The list to populate the JList with.
* @return A JList populated with the elements from ls.
*/
- public static <E> JList<E> buildFromList(Iterable<E> listSource) {
- if (listSource == null) {
+ public static <E> JList<E> buildFromList(Iterable<E> source) {
+ if (source == null) {
throw new NullPointerException("Source must not be null");
}
- return new JList<>(buildModel(listSource));
+ return new JList<>(buildModel(source));
}
/**
@@ -35,18 +35,18 @@ public class SimpleJList {
* @param <E>
* The type of data in the list model
*
- * @param listSource
+ * @param source
* The list to fill the list model from.
* @return A list model populated with the elements from ls.
*/
- public static <E> ListModel<E> buildModel(Iterable<E> listSource) {
- if (listSource == null) {
+ public static <E> ListModel<E> buildModel(Iterable<E> source) {
+ if (source == null) {
throw new NullPointerException("Source must not be null");
}
DefaultListModel<E> defaultModel = new DefaultListModel<>();
- listSource.forEach(defaultModel::addElement);
+ source.forEach(defaultModel::addElement);
return defaultModel;
}
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/TextAreaOutputStream.java b/BJC-Utils2/src/main/java/bjc/utils/gui/TextAreaOutputStream.java
index 6080462..6ff716b 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/TextAreaOutputStream.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/TextAreaOutputStream.java
@@ -6,11 +6,12 @@ import java.io.OutputStream;
import javax.swing.JTextArea;
/**
+ * An output stream that prints to a JTextArea
+ *
* @author epr
* @author Levente S\u00e1ntha (lsantha@users.sourceforge.net)
*/
public class TextAreaOutputStream extends OutputStream {
-
private JTextArea textArea;
/**
@@ -26,8 +27,9 @@ public class TextAreaOutputStream extends OutputStream {
@Override
public void write(int b) throws IOException {
textArea.append("" + (char) b);
+
if (b == '\n') {
textArea.repaint();
}
}
-} \ 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 79ba4be..280c5d8 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
@@ -48,23 +48,23 @@ public class SimpleFileDialog {
throw new NullPointerException("Title must not be null");
}
- FileDialog fileDialog = new FileDialog(parent, title,
+ FileDialog chooser = new FileDialog(parent, title,
FileDialog.LOAD);
if (extensions != null) {
FilenameFilter filter = new ExtensionFileFilter(extensions);
- fileDialog.setFilenameFilter(filter);
+ chooser.setFilenameFilter(filter);
}
- fileDialog.setVisible(true);
+ chooser.setVisible(true);
- while (fileDialog.getFile() == null) {
+ while (chooser.getFile() == null) {
SimpleDialogs.showError(parent, "File I/O Error",
"Please choose a file to open.");
- fileDialog.setVisible(true);
+ chooser.setVisible(true);
}
- return fileDialog.getFiles()[0];
+ return chooser.getFiles()[0];
}
/**
@@ -86,24 +86,24 @@ public class SimpleFileDialog {
throw new NullPointerException("Title must not be null");
}
- FileDialog fileDialog = new FileDialog(parent, title,
+ FileDialog chooser = new FileDialog(parent, title,
FileDialog.LOAD);
if (extensions != null) {
FilenameFilter filter = new ExtensionFileFilter(extensions);
- fileDialog.setFilenameFilter(filter);
+ chooser.setFilenameFilter(filter);
}
- fileDialog.setMultipleMode(true);
- fileDialog.setVisible(true);
+ chooser.setMultipleMode(true);
+ chooser.setVisible(true);
- while (fileDialog.getFile() == null) {
+ while (chooser.getFile() == null) {
SimpleDialogs.showError(parent, "File I/O Error",
"Please choose a file to open.");
- fileDialog.setVisible(true);
+ chooser.setVisible(true);
}
- return fileDialog.getFiles();
+ return chooser.getFiles();
}
/**
@@ -138,22 +138,22 @@ public class SimpleFileDialog {
throw new NullPointerException("Title must not be null");
}
- FileDialog fileDialog = new FileDialog(parent, title,
+ FileDialog chooser = new FileDialog(parent, title,
FileDialog.SAVE);
if (extensions != null) {
FilenameFilter filter = new ExtensionFileFilter(extensions);
- fileDialog.setFilenameFilter(filter);
+ chooser.setFilenameFilter(filter);
}
- fileDialog.setVisible(true);
+ chooser.setVisible(true);
- while (fileDialog.getFile() == null) {
+ while (chooser.getFile() == null) {
SimpleDialogs.showError(parent, "File I/O Error",
"Please choose a file to save to.");
- fileDialog.setVisible(true);
+ chooser.setVisible(true);
}
- return fileDialog.getFiles()[0];
+ return chooser.getFiles()[0];
}
}
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);
}
});