Class SpinnerValueFactory.DoubleSpinnerValueFactory
java.lang.Object
javafx.scene.control.SpinnerValueFactory<Double>
javafx.scene.control.SpinnerValueFactory.DoubleSpinnerValueFactory
- Enclosing class:
- SpinnerValueFactory<T>
public static class SpinnerValueFactory.DoubleSpinnerValueFactory
extends SpinnerValueFactory<Double>
A 
SpinnerValueFactory implementation designed to iterate through
 double values.
 
 If wrapAround is true, the
 DoubleSpinnerValueFactory will step through from the maximum value to the minimum value seamlessly; that
 is, any step up from the maximum value is equal to the same step up from the minimum value (and vice versa).
 The new value after a step is val = (val + amountToStepBy) % (max - min).
 
 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
- 
Nested Class SummaryNested classes/interfaces declared in class javafx.scene.control.SpinnerValueFactorySpinnerValueFactory.DoubleSpinnerValueFactory, SpinnerValueFactory.IntegerSpinnerValueFactory, SpinnerValueFactory.ListSpinnerValueFactory<T>
- 
Property SummaryPropertiesTypePropertyDescriptionfinal DoublePropertySets the amount to increment or decrement by, per step.final DoublePropertySets the maximum allowable value for this value factoryfinal DoublePropertySets the minimum allowable value for this value factoryProperties declared in class javafx.scene.control.SpinnerValueFactoryconverter, value, wrapAround
- 
Constructor SummaryConstructorsConstructorDescriptionDoubleSpinnerValueFactory(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 SummaryModifier and TypeMethodDescriptionfinal DoublePropertySets the amount to increment or decrement by, per step.voiddecrement(int steps) Attempts to decrement thevalueby the given number of steps.final doubleGets the value of theamountToStepByproperty.final doublegetMax()Gets the value of themaxproperty.final doublegetMin()Gets the value of theminproperty.voidincrement(int steps) Attempts to increment thevalueby the given number of steps.final DoublePropertySets the maximum allowable value for this value factoryfinal DoublePropertySets the minimum allowable value for this value factoryfinal voidsetAmountToStepBy(double value) Sets the value of theamountToStepByproperty.final voidsetMax(double value) Sets the value of themaxproperty.final voidsetMin(double value) Sets the value of theminproperty.Methods declared in class javafx.scene.control.SpinnerValueFactoryconverterProperty, getConverter, getValue, isWrapAround, setConverter, setValue, setWrapAround, valueProperty, wrapAroundProperty
- 
Property Details- 
minSets the minimum allowable value for this value factory- See Also:
 
- 
maxSets the maximum allowable value for this value factory- See Also:
 
- 
amountToStepBySets the amount to increment or decrement by, per step.- See Also:
 
 
- 
- 
Constructor Details- 
DoubleSpinnerValueFactorypublic 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.
- max- The maximum allowed double value for the Spinner.
 
- 
DoubleSpinnerValueFactorypublic 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.
- 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.
 
- 
DoubleSpinnerValueFactorypublic DoubleSpinnerValueFactory(double min, double max, double initialValue, double amountToStepBy) Constructs a new DoubleSpinnerValueFactory.- Parameters:
- 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.
 
 
- 
- 
Method Details- 
setMinpublic final void setMin(double value) Sets the value of theminproperty.- Property description:
- Sets the minimum allowable value for this value factory
- Parameters:
- value- the value for the- minproperty
- See Also:
 
- 
getMinpublic final double getMin()Gets the value of theminproperty.- Property description:
- Sets the minimum allowable value for this value factory
- Returns:
- the value of the minproperty
- See Also:
 
- 
minPropertySets the minimum allowable value for this value factory- Returns:
- the minimum allowable value for this value factory
- See Also:
 
- 
setMaxpublic final void setMax(double value) Sets the value of themaxproperty.- Property description:
- Sets the maximum allowable value for this value factory
- Parameters:
- value- the value for the- maxproperty
- See Also:
 
- 
getMaxpublic final double getMax()Gets the value of themaxproperty.- Property description:
- Sets the maximum allowable value for this value factory
- Returns:
- the value of the maxproperty
- See Also:
 
- 
maxPropertySets the maximum allowable value for this value factory- Returns:
- the maximum allowable value for this value factory
- See Also:
 
- 
setAmountToStepBypublic final void setAmountToStepBy(double value) Sets the value of theamountToStepByproperty.- Property description:
- Sets the amount to increment or decrement by, per step.
- Parameters:
- value- the value for the- amountToStepByproperty
- See Also:
 
- 
getAmountToStepBypublic final double getAmountToStepBy()Gets the value of theamountToStepByproperty.- Property description:
- Sets the amount to increment or decrement by, per step.
- Returns:
- the value of the amountToStepByproperty
- See Also:
 
- 
amountToStepByPropertySets the amount to increment or decrement by, per step.- Returns:
- the amount to increment or decrement by, per step
- See Also:
 
- 
decrementpublic void decrement(int steps) Attempts to decrement thevalueby the given number of steps.- Specified by:
- decrementin class- SpinnerValueFactory<Double>
- Parameters:
- steps- The number of decrements that should be performed on the value. If the number is negative, the call is equivalent to calling- SpinnerValueFactory.increment(int)with the absolute value of- steps.
 
- 
incrementpublic void increment(int steps) Attempts to increment thevalueby the given number of steps.- Specified by:
- incrementin class- SpinnerValueFactory<Double>
- Parameters:
- steps- The number of increments that should be performed on the value. If the number is negative, the call is equivalent to calling- SpinnerValueFactory.decrement(int)with the absolute number of- steps.
 
 
-