diff options
| author | EVE <EVE@EVE-PC> | 2017-03-13 16:42:21 -0400 |
|---|---|---|
| committer | EVE <EVE@EVE-PC> | 2017-03-13 16:42:21 -0400 |
| commit | 27bf571d6413c3cc6a5d664b5bddd38d21d7b1cd (patch) | |
| tree | 847fb52acb091c1c613d37b8477094d5762c6988 /BJC-Utils2/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java | |
| parent | aa807a96cae2c47259fb38f710640883060339e9 (diff) | |
Formatting
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/gui/panels/SliderInputPanel.java | 65 |
1 files changed, 30 insertions, 35 deletions
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 9de4d63..53bff32 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 @@ -11,21 +11,20 @@ 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 + * A simple input panel for a slider-controlled value and a manual-input field + * for setting the slider * * @author ben * */ public class SliderInputPanel extends JPanel { - private final class NumberFormatter - extends JFormattedTextField.AbstractFormatter { - private static final long serialVersionUID = -4448291795913908270L; + 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; + private int initValue; public NumberFormatter(SliderSettings settings) { minValue = settings.minValue; @@ -40,17 +39,14 @@ public class SliderInputPanel extends JPanel { int val = Integer.parseInt(text); if (val < minValue) { - throw new ParseException( - "Value must be greater than " + minValue, 0); + throw new ParseException("Value must be greater than " + minValue, 0); } else if (val > maxValue) { - throw new ParseException( - "Value must be smaller than " + maxValue, 0); + throw new ParseException("Value must be smaller than " + maxValue, 0); } else { return val; } } catch (NumberFormatException nfex) { - ParseException pex = new ParseException( - "Value must be a valid integer", 0); + ParseException pex = new ParseException("Value must be a valid integer", 0); pex.initCause(nfex); @@ -78,25 +74,25 @@ 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 */ - public final int initValue; + public final int initValue; /** * Create a new slider settings, with the initial value in the * middle * * @param min - * The minimum value of the slider + * The minimum value of the slider * @param max - * The maximum value of the slider + * The maximum value of the slider */ public SliderSettings(int min, int max) { this(min, max, (min + max) / 2); @@ -106,11 +102,11 @@ public class SliderInputPanel extends JPanel { * Create a new set of slider sttings * * @param min - * The minimum slider value + * The minimum slider value * @param max - * The maximum slider value + * The maximum slider value * @param init - * Th initial slider value + * Th initial slider value */ public SliderSettings(int min, int max, int init) { minValue = min; @@ -120,32 +116,31 @@ 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 + * The label for the field * @param settings - * The settings for slider values + * The settings for slider values * @param majorTick - * The setting for where to place big ticks + * The setting for where to place big ticks * @param minorTick - * The setting for where to place small ticks + * The setting for where to place small ticks * @param action - * The action to execute for a given value + * The action to execute for a given value */ - public SliderInputPanel(String lab, SliderSettings settings, - int majorTick, int minorTick, Consumer<Integer> action) { + public SliderInputPanel(String lab, SliderSettings settings, int majorTick, int minorTick, + Consumer<Integer> action) { setLayout(new HLayout(3)); JLabel label = new JLabel(lab); - slider = new JSlider(settings.minValue, settings.maxValue, - settings.initValue); + slider = new JSlider(settings.minValue, settings.maxValue, settings.initValue); field = new JFormattedTextField(new NumberFormatter(settings)); slider.setMajorTickSpacing(majorTick); @@ -186,7 +181,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 + * The value to reset the fields to */ public void resetValues(int value) { slider.setValue(value); |
