Module javafx.base

Class IntegerProperty

All Implemented Interfaces:
NumberExpression, Observable, Property<Number>, ReadOnlyProperty<Number>, ObservableIntegerValue, ObservableNumberValue, ObservableValue<Number>, WritableIntegerValue, WritableNumberValue, WritableValue<Number>
Direct Known Subclasses:
IntegerPropertyBase, JavaBeanIntegerProperty

public abstract class IntegerProperty
extends ReadOnlyIntegerProperty
implements Property<Number>, WritableIntegerValue
This class defines a Property wrapping an int value.

The value of an IntegerProperty can be get and set with ObservableIntegerValue.get(), ObservableValue.getValue(), WritableIntegerValue.set(int), and WritableIntegerValue.setValue(Number).

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

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

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

JavaFX 2.0
See Also:
ObservableIntegerValue, WritableIntegerValue, ReadOnlyIntegerProperty, Property
  • Constructor Details

    • IntegerProperty

      public IntegerProperty()
      Creates a default IntegerProperty.
  • Method Details

    • toString

      public String toString()
      Returns a string representation of this IntegerProperty object.
      toString in class ReadOnlyIntegerProperty
      a string representation of this IntegerProperty object.
    • integerProperty

      public static IntegerProperty integerProperty​(Property<Integer> property)
      Returns a IntegerProperty that wraps a 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<Integer> and a IntegerProperty.

         IntegerProperty integerProperty = new SimpleIntegerProperty(1);
         ObjectProperty<Integer> objectProperty = new SimpleObjectProperty<>(2);
         // Need to keep the reference as bidirectional binding uses weak references
         IntegerProperty objectAsInteger = IntegerProperty.integerProperty(objectProperty);
      Another approach is to convert the IntegerProperty to ObjectProperty using asObject() method.

      Note: null values in the source property will be interpreted as 0

      property - The source Property
      A IntegerProperty that wraps the Property
      NullPointerException - if property is null
      JavaFX 8.0
      See Also:
    • asObject

      public ObjectProperty<Integer> asObject()
      Creates an ObjectProperty that bidirectionally bound to this IntegerProperty. If the value of this IntegerProperty changes, the value of the ObjectProperty will be updated automatically and vice-versa.

      Can be used for binding an ObjectProperty to IntegerProperty.

         IntegerProperty integerProperty = new SimpleIntegerProperty(1);
         ObjectProperty<Integer> objectProperty = new SimpleObjectProperty<>(2);
      asObject in class ReadOnlyIntegerProperty
      the new ObjectProperty
      JavaFX 8.0