public static class SpinnerValueFactory.DoubleSpinnerValueFactory extends SpinnerValueFactory<Double>
SpinnerValueFactory
implementation designed to iterate through
double values.
Note that the default converter
is implemented
simply as shown below, which may be adequate in many cases, but it is important
for users to ensure that this suits their needs (and adjust when necessary). The
main point to note is that this StringConverter
embeds
within it a DecimalFormat
instance that shows the Double
to two decimal places. This is used for both the toString and fromString
methods:
setConverter(new StringConverter<Double>() { private final DecimalFormat df = new DecimalFormat("#.##"); @Override public String toString(Double value) { // If the specified value is null, return a zero-length String if (value == null) { return ""; } return df.format(value); } @Override public Double fromString(String value) { try { // If the specified value is null or zero-length, return null if (value == null) { return null; } value = value.trim(); if (value.length() < 1) { return null; } // Perform the requested parsing return df.parse(value).doubleValue(); } catch (ParseException ex) { throw new RuntimeException(ex); } } });
Type | Property and Description |
---|---|
DoubleProperty |
amountToStepBy
Sets the amount to increment or decrement by, per step.
|
DoubleProperty |
max
Sets the maximum allowable value for this value factory
|
DoubleProperty |
min
Sets the minimum allowable value for this value factory
|
converter, value, wrapAround
SpinnerValueFactory.DoubleSpinnerValueFactory, SpinnerValueFactory.IntegerSpinnerValueFactory, SpinnerValueFactory.ListSpinnerValueFactory<T>
Constructor and Description |
---|
DoubleSpinnerValueFactory(double min,
double max)
Constructs a new DoubleSpinnerValueFactory that sets the initial value
to be equal to the min value, and a default
amountToStepBy of
one. |
DoubleSpinnerValueFactory(double min,
double max,
double initialValue)
Constructs a new DoubleSpinnerValueFactory with a default
amountToStepBy of one. |
DoubleSpinnerValueFactory(double min,
double max,
double initialValue,
double amountToStepBy)
Constructs a new DoubleSpinnerValueFactory.
|
Modifier and Type | Method and Description |
---|---|
DoubleProperty |
amountToStepByProperty()
Sets the amount to increment or decrement by, per step.
|
void |
decrement(int steps)
Attempts to decrement the
value by the given
number of steps. |
double |
getAmountToStepBy()
Gets the value of the property amountToStepBy.
|
double |
getMax()
Gets the value of the property max.
|
double |
getMin()
Gets the value of the property min.
|
void |
increment(int steps)
Attempts to omcrement the
value by the given
number of steps. |
DoubleProperty |
maxProperty()
Sets the maximum allowable value for this value factory
|
DoubleProperty |
minProperty()
Sets the minimum allowable value for this value factory
|
void |
setAmountToStepBy(double value)
Sets the value of the property amountToStepBy.
|
void |
setMax(double value)
Sets the value of the property max.
|
void |
setMin(double value)
Sets the value of the property min.
|
converterProperty, getConverter, getValue, isWrapAround, setConverter, setValue, setWrapAround, valueProperty, wrapAroundProperty
public final DoubleProperty minProperty
public final DoubleProperty maxProperty
getMax()
,
setMax(double)
public final DoubleProperty amountToStepByProperty
getAmountToStepBy()
,
setAmountToStepBy(double)
public DoubleSpinnerValueFactory(double min, double max)
amountToStepBy
of
one.min
- The minimum allowed double value for the Spinner.max
- The maximum allowed double value for the Spinner.public DoubleSpinnerValueFactory(double min, double max, double initialValue)
amountToStepBy
of one.min
- The minimum allowed double value for the Spinner.max
- The maximum allowed double value for the Spinner.initialValue
- The value of the Spinner when first instantiated, must
be within the bounds of the min and max arguments, or
else the min value will be used.public DoubleSpinnerValueFactory(double min, double max, double initialValue, double amountToStepBy)
min
- The minimum allowed double value for the Spinner.max
- The maximum allowed double value for the Spinner.initialValue
- The value of the Spinner when first instantiated, must
be within the bounds of the min and max arguments, or
else the min value will be used.amountToStepBy
- The amount to increment or decrement by, per step.public final void setMin(double value)
public final double getMin()
public final DoubleProperty minProperty()
public final void setMax(double value)
public final double getMax()
public final DoubleProperty maxProperty()
getMax()
,
setMax(double)
public final void setAmountToStepBy(double value)
public final double getAmountToStepBy()
public final DoubleProperty amountToStepByProperty()
getAmountToStepBy()
,
setAmountToStepBy(double)
public void decrement(int steps)
value
by the given
number of steps.decrement
in class SpinnerValueFactory<Double>
steps
- The number of decrements that should be performed on the value.public void increment(int steps)
value
by the given
number of steps.increment
in class SpinnerValueFactory<Double>
steps
- The number of increments that should be performed on the value.Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.