Top Description Constructors Methods
javafx.beans.property

public abstract Class DoubleProperty

extends ReadOnlyDoubleProperty
implements Property<Number>, WritableDoubleValue
Class Inheritance
All Implemented Interfaces
javafx.beans.value.WritableDoubleValue, javafx.beans.value.WritableNumberValue, javafx.beans.value.WritableValue, javafx.beans.property.Property, javafx.beans.property.ReadOnlyProperty, javafx.beans.value.ObservableValue, javafx.beans.Observable
Known Direct Subclasses
javafx.beans.property.DoublePropertyBase, javafx.beans.property.adapter.JavaBeanDoubleProperty
Imports
java.util.Objects, com.sun.javafx.binding.BidirectionalBinding, .Logging, javafx.beans.binding.Bindings, javafx.beans.value.ObservableValue, .WritableDoubleValue

This class defines a Property wrapping a double value.

The value of a DoubleProperty can be get and set with get(), getValue(), set(double), and setValue(Number).

A property can be bound and unbound unidirectional with bind(ObservableValue) and unbind(). Bidirectional bindings can be created and removed with bindBidirectional(Property) and unbindBidirectional(Property).

The context of a DoubleProperty can be read with getBean() and getName().

Note

setting or binding this property to a null value will set the property to "0.0". See setValue(java.lang.Number).

Since
JavaFX 2.0
See Also
javafx.beans.value.ObservableDoubleValue, javafx.beans.value.WritableDoubleValue, ReadOnlyDoubleProperty, Property

Constructor Summary

AccessConstructor and Description
public
DoubleProperty()

Creates a default DoubleProperty.

Method Summary

Modifier and TypeMethod and Description
public ObjectProperty<Double>

Returns:

the new ObjectProperty
asObject
()

Overrides javafx.beans.property.ReadOnlyDoubleProperty.asObject.

Creates an javafx.beans.property.ObjectProperty that bidirectionally bound to this DoubleProperty.

public void
bindBidirectional(Property<Number>
the other Property
other
)

Implements javafx.beans.property.Property.bindBidirectional.

Create a bidirectional binding between this Property and another one.

public static DoubleProperty

Returns:

A DoubleProperty that wraps the Property
doubleProperty
(final Property<Double>
The source Property
property
)

Returns a DoubleProperty that wraps a javafx.beans.property.Property and is bidirectionally bound to it.

public void
public String

Returns:

a string representation of this DoubleProperty object.
toString
()

Overrides javafx.beans.property.ReadOnlyDoubleProperty.toString.

Returns a string representation of this DoubleProperty object.

public void
unbindBidirectional(Property<Number>
the other Property
other
)

Implements javafx.beans.property.Property.unbindBidirectional.

Removes a bidirectional binding between this Property and another one.

Inherited from javafx.beans.property.ReadOnlyDoubleProperty:
readOnlyDoubleProperty

Constructor Detail

DoublePropertyback to summary
public DoubleProperty()

Creates a default DoubleProperty.

Method Detail

asObjectback to summary
public ObjectProperty<Double> asObject()

Overrides javafx.beans.property.ReadOnlyDoubleProperty.asObject.

Creates an javafx.beans.property.ObjectProperty that bidirectionally bound to this DoubleProperty. If the value of this DoubleProperty changes, the value of the ObjectProperty will be updated automatically and vice-versa.

Can be used for binding an ObjectProperty to DoubleProperty.

  DoubleProperty doubleProperty = new SimpleDoubleProperty(1.0);
  ObjectProperty<Double> objectProperty = new SimpleObjectProperty<>(2.0);

  objectProperty.bind(doubleProperty.asObject());
Returns:ObjectProperty<Double>

the new ObjectProperty

Annotations
@Override
Since
JavaFX 8.0
bindBidirectionalback to summary
public void bindBidirectional(Property<Number> other)

Implements javafx.beans.property.Property.bindBidirectional.

Doc from javafx.beans.property.Property.bindBidirectional.

Create a bidirectional binding between this Property and another one. Bidirectional bindings exists independently of unidirectional bindings. So it is possible to add unidirectional binding to a property with bidirectional binding and vice-versa. However, this practice is discouraged.

It is possible to have multiple bidirectional bindings of one Property.

JavaFX bidirectional binding implementation use weak listeners. This means bidirectional binding does not prevent properties from being garbage collected.

Parameters
other:Property<Number>

the other Property

Annotations
@Override
doublePropertyback to summary
public static DoubleProperty doubleProperty(final Property<Double> property)

Returns a DoubleProperty that wraps a javafx.beans.property.Property and is bidirectionally bound to it. Changing this property will result in a change of the original property.

This is very useful when bidirectionally binding an ObjectProperty<Double> and a DoubleProperty.

  DoubleProperty doubleProperty = new SimpleDoubleProperty(1.0);
  ObjectProperty<Double> objectProperty = new SimpleObjectProperty<>(2.0);

  // Need to keep the reference as bidirectional binding uses weak references
  DoubleProperty objectAsDouble = DoubleProperty.doubleProperty(objectProperty);

  doubleProperty.bindBidirectional(objectAsDouble);

Another approach is to convert the DoubleProperty to ObjectProperty using asObject() method.

Note

null values in the source property will be interpreted as 0.0

Parameters
property:Property<Double>

The source Property

Returns:DoubleProperty

A DoubleProperty that wraps the Property

Exceptions
NullPointerException:
if property is null
Since
JavaFX 8.0
See Also
asObject()
setValueback to summary
public void setValue(Number v)

Implements javafx.beans.value.WritableValue.setValue, javafx.beans.value.WritableDoubleValue.setValue.

Doc from javafx.beans.value.WritableDoubleValue.setValue.

Set the wrapped value.

Note

this method should accept null without throwing an exception, setting "0.0" instead.

Parameters
v:Number

The new value

Annotations
@Override
toStringback to summary
public String toString()

Overrides javafx.beans.property.ReadOnlyDoubleProperty.toString.

Returns a string representation of this DoubleProperty object.

Returns:String

a string representation of this DoubleProperty object.

Annotations
@Override
unbindBidirectionalback to summary
public void unbindBidirectional(Property<Number> other)

Implements javafx.beans.property.Property.unbindBidirectional.

Doc from javafx.beans.property.Property.unbindBidirectional.

Removes a bidirectional binding between this Property and another one. If no bidirectional binding between the properties exists, calling this method has no effect. It is possible to unbind by a call on the second property. This code will work:

    property1.bindBidirectional(property2);
    property2.unbindBidirectional(property1);
Parameters
other:Property<Number>

the other Property

Annotations
@Override