Class SpinnerValueFactory.DoubleSpinnerValueFactory
- javafx.scene.control.SpinnerValueFactory<Double>
-
- javafx.scene.control.SpinnerValueFactory.DoubleSpinnerValueFactory
Enclosing class:
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);
}
}
});
Since:
JavaFX 8u40
-
Property Summary
All MethodsInstance MethodsConcrete Methods Type Property and Description DoublePropertyamountToStepBySets the amount to increment or decrement by, per step.DoublePropertymaxSets the maximum allowable value for this value factoryDoublePropertyminSets the minimum allowable value for this value factory-
Properties inherited from class javafx.scene.control.SpinnerValueFactory
converter, value, wrapAround
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javafx.scene.control.SpinnerValueFactory
SpinnerValueFactory.DoubleSpinnerValueFactory, SpinnerValueFactory.IntegerSpinnerValueFactory, SpinnerValueFactory.ListSpinnerValueFactory<T>
-
-
Constructor Summary
Constructors 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 defaultamountToStepByof one.DoubleSpinnerValueFactory(double min, double max, double initialValue)Constructs a new DoubleSpinnerValueFactory with a defaultamountToStepByof one.DoubleSpinnerValueFactory(double min, double max, double initialValue, double amountToStepBy)Constructs a new DoubleSpinnerValueFactory.
-
Method Summary
All MethodsInstance MethodsConcrete Methods Modifier and Type Method and Description DoublePropertyamountToStepByProperty()Sets the amount to increment or decrement by, per step.voiddecrement(int steps)Attempts to decrement thevalueby the given number of steps.doublegetAmountToStepBy()Gets the value of the property amountToStepBy.doublegetMax()Gets the value of the property max.doublegetMin()Gets the value of the property min.voidincrement(int steps)Attempts to omcrement thevalueby the given number of steps.DoublePropertymaxProperty()Sets the maximum allowable value for this value factoryDoublePropertyminProperty()Sets the minimum allowable value for this value factoryvoidsetAmountToStepBy(double value)Sets the value of the property amountToStepBy.voidsetMax(double value)Sets the value of the property max.voidsetMin(double value)Sets the value of the property min.-
Methods inherited from class javafx.scene.control.SpinnerValueFactory
converterProperty, getConverter, getValue, isWrapAround, setConverter, setValue, setWrapAround, valueProperty, wrapAroundProperty
-
-
Property Detail
-
min
public final DoubleProperty minProperty
Sets the minimum allowable value for this value factory
-
max
public final DoubleProperty maxProperty
Sets the maximum allowable value for this value factorySee Also:
-
amountToStepBy
public final DoubleProperty amountToStepByProperty
Sets the amount to increment or decrement by, per step.See Also:
-
-
Constructor Detail
-
DoubleSpinnerValueFactory
public DoubleSpinnerValueFactory(double min, double max)Constructs a new DoubleSpinnerValueFactory that sets the initial value to be equal to the min value, and a defaultamountToStepByof one.Parameters:
min- The minimum allowed double value for the Spinner.
-
DoubleSpinnerValueFactory
public DoubleSpinnerValueFactory(double min, double max, double initialValue)Constructs a new DoubleSpinnerValueFactory with a defaultamountToStepByof one.Parameters:
min- The minimum allowed double value for the Spinner.
-
DoubleSpinnerValueFactory
public DoubleSpinnerValueFactory(double min, double max, double initialValue, double amountToStepBy)Constructs a new DoubleSpinnerValueFactory.Parameters:
min- The minimum allowed double value for the Spinner.
-
-
Method Detail
-
setMin
public final void setMin(double value)
Sets the value of the property min.Property description:
* Properties * *
-
getMin
public final double getMin()
Gets the value of the property min.Property description:
* Properties * *
-
minProperty
public final DoubleProperty minProperty()
Sets the minimum allowable value for this value factory
-
setMax
public final void setMax(double value)
Sets the value of the property max.Property description:
Sets the maximum allowable value for this value factory
-
getMax
public final double getMax()
Gets the value of the property max.Property description:
Sets the maximum allowable value for this value factory
-
maxProperty
public final DoubleProperty maxProperty()
Sets the maximum allowable value for this value factorySee Also:
-
setAmountToStepBy
public final void setAmountToStepBy(double value)
Sets the value of the property amountToStepBy.Property description:
Sets the amount to increment or decrement by, per step.
-
getAmountToStepBy
public final double getAmountToStepBy()
Gets the value of the property amountToStepBy.Property description:
Sets the amount to increment or decrement by, per step.
-
amountToStepByProperty
public final DoubleProperty amountToStepByProperty()
Sets the amount to increment or decrement by, per step.See Also:
-
decrement
public void decrement(int steps)
Attempts to decrement thevalueby the given number of steps.Specified by:
decrementin classSpinnerValueFactory<Double>Parameters:
steps- The number of decrements that should be performed on the value.
-
increment
public void increment(int steps)
Attempts to omcrement thevalueby the given number of steps.Specified by:
incrementin classSpinnerValueFactory<Double>Parameters:
steps- The number of increments that should be performed on the value.
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.