Spec-Zone.ru › OpenJavaFX 17

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.

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

Properties
Type Property 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

Properties declared in class javafx.scene.control.SpinnerValueFactory

converter, value, wrapAround

Nested Class Summary

Nested classes/interfaces declared in class javafx.scene.control.SpinnerValueFactory

SpinnerValueFactory.DoubleSpinnerValueFactory, SpinnerValueFactory.IntegerSpinnerValueFactory, SpinnerValueFactory.ListSpinnerValueFactory<T>

Constructor Summary

Constructors
Constructor 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.

Method Summary

Modifier and Type Method Description
DoubleProperty amountToStepByProperty()
Sets the amount to increment or decrement by, per step.
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.
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.

Methods declared in class javafx.scene.control.SpinnerValueFactory

converterProperty, decrement, getConverter, getValue, increment, isWrapAround, setConverter, setValue, setWrapAround, valueProperty, wrapAroundProperty

Methods declared in class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Property Details

min

public final DoubleProperty minProperty
Sets the minimum allowable value for this value factory
See Also:
getMin(), setMin(double)

max

public final DoubleProperty maxProperty
Sets the maximum allowable value for this value factory
See Also:
getMax(), setMax(double)

amountToStepBy

public final DoubleProperty amountToStepByProperty
Sets the amount to increment or decrement by, per step.
See Also:
getAmountToStepBy(), setAmountToStepBy(double)

Constructor Details

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 default amountToStepBy of one.
Parameters:
min - The minimum allowed double value for the Spinner.
max - The maximum allowed double value for the Spinner.

DoubleSpinnerValueFactory

public DoubleSpinnerValueFactory(double min, double max, double initialValue)
Constructs a new DoubleSpinnerValueFactory with a default amountToStepBy of 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.

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.
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

setMin

public final void setMin(double value)
Sets the value of the property min.
Property description:
Sets the minimum allowable value for this value factory

getMin

public final double getMin()
Gets the value of the property min.
Property description:
Sets the minimum allowable value for this value factory

minProperty

public final DoubleProperty minProperty()
Sets the minimum allowable value for this value factory
See Also:
getMin(), setMin(double)

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 factory
See Also:
getMax(), setMax(double)

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:
getAmountToStepBy(), setAmountToStepBy(double)

© 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.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API