Top Description Constructors Methods
javafx.beans.property

public abstract Class LongProperty

extends ReadOnlyLongProperty
implements Property<Number>, WritableLongValue
Class Inheritance
All Implemented Interfaces
javafx.beans.value.WritableLongValue, 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.LongPropertyBase, javafx.beans.property.adapter.JavaBeanLongProperty
Imports
java.util.Objects, com.sun.javafx.binding.BidirectionalBinding, .Logging, javafx.beans.binding.Bindings, javafx.beans.value.ObservableValue, .WritableLongValue

This class defines a Property wrapping a long value.

The value of a LongProperty can be get and set with get(), getValue(), set(long), 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 LongProperty 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.ObservableLongValue, javafx.beans.value.WritableLongValue, ReadOnlyLongProperty, Property

Constructor Summary

AccessConstructor and Description
public
LongProperty()

Creates a default LongProperty.

Method Summary

Modifier and TypeMethod and Description
public ObjectProperty<Long>

Returns:

the new ObjectProperty
asObject
()

Overrides javafx.beans.property.ReadOnlyLongProperty.asObject.

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

public void
bindBidirectional(Property<Number> other)

Implements javafx.beans.property.Property.bindBidirectional.

Create a bidirectional binding between this Property and another one.

public static LongProperty

Returns:

A LongProperty that wraps the Property
longProperty
(final Property<Long>
The source Property
property
)

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

public void
public String

Returns:

a string representation of this LongProperty object.
toString
()

Overrides javafx.beans.property.ReadOnlyLongProperty.toString.

Returns a string representation of this LongProperty object.

public void
unbindBidirectional(Property<Number> other)

Implements javafx.beans.property.Property.unbindBidirectional.

Removes a bidirectional binding between this Property and another one.

Inherited from javafx.beans.property.ReadOnlyLongProperty:
readOnlyLongProperty

Constructor Detail

LongPropertyback to summary
public LongProperty()

Creates a default LongProperty.

Method Detail

asObjectback to summary
public ObjectProperty<Long> asObject()

Overrides javafx.beans.property.ReadOnlyLongProperty.asObject.

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

Can be used for binding an ObjectProperty to LongProperty.

  LongProperty longProperty = new SimpleLongProperty(1L);
  ObjectProperty<Long> objectProperty = new SimpleObjectProperty<>(2L);

  objectProperty.bind(longProperty.asObject());
Returns:ObjectProperty<Long>

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.

Annotations
@Override
longPropertyback to summary
public static LongProperty longProperty(final Property<Long> property)

Returns a LongProperty 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<Long> and a LongProperty.

  LongProperty longProperty = new SimpleLongProperty(1L);
  ObjectProperty<Long> objectProperty = new SimpleObjectProperty<>(2L);

  // Need to keep the reference as bidirectional binding uses weak references
  LongProperty objectAsLong = LongProperty.longProperty(objectProperty);

  longProperty.bindBidirectional(objectAsLong);

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

Note

null values in the source property will be interpreted as 0L

Parameters
property:Property<Long>

The source Property

Returns:LongProperty

A LongProperty 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.WritableLongValue.setValue.

Doc from javafx.beans.value.WritableLongValue.setValue.

Set the wrapped value.

Note

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

Annotations
@Override
toStringback to summary
public String toString()

Overrides javafx.beans.property.ReadOnlyLongProperty.toString.

Returns a string representation of this LongProperty object.

Returns:String

a string representation of this LongProperty 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);
Annotations
@Override