Interface Property<T>
- Type Parameters:
T- the type of the wrapped value
- All Superinterfaces:
Observable, ObservableValue<T>, ReadOnlyProperty<T>, WritableValue<T>
- All Known Subinterfaces:
JavaBeanProperty<T>
- All Known Implementing Classes:
BooleanProperty, BooleanPropertyBase, DoubleProperty, DoublePropertyBase, FloatProperty, FloatPropertyBase, IntegerProperty, IntegerPropertyBase, JavaBeanBooleanProperty, JavaBeanDoubleProperty, JavaBeanFloatProperty, JavaBeanIntegerProperty, JavaBeanLongProperty, JavaBeanObjectProperty, JavaBeanStringProperty, ListProperty, ListPropertyBase, LongProperty, LongPropertyBase, MapProperty, MapPropertyBase, ObjectProperty, ObjectPropertyBase, ReadOnlyBooleanWrapper, ReadOnlyDoubleWrapper, ReadOnlyFloatWrapper, ReadOnlyIntegerWrapper, ReadOnlyListWrapper, ReadOnlyLongWrapper, ReadOnlyMapWrapper, ReadOnlyObjectWrapper, ReadOnlySetWrapper, ReadOnlyStringWrapper, SetProperty, SetPropertyBase, SimpleBooleanProperty, SimpleDoubleProperty, SimpleFloatProperty, SimpleIntegerProperty, SimpleListProperty, SimpleLongProperty, SimpleMapProperty, SimpleObjectProperty, SimpleSetProperty, SimpleStringProperty, SimpleStyleableBooleanProperty, SimpleStyleableDoubleProperty, SimpleStyleableFloatProperty, SimpleStyleableIntegerProperty, SimpleStyleableLongProperty, SimpleStyleableObjectProperty, SimpleStyleableStringProperty, StringProperty, StringPropertyBase, StyleableBooleanProperty, StyleableDoubleProperty, StyleableFloatProperty, StyleableIntegerProperty, StyleableLongProperty, StyleableObjectProperty, StyleableStringProperty
Generic interface that defines the methods common to all (writable)
properties, independent of their type.
- Since:
- JavaFX 2.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidbind(ObservableValue<? extends T> observable) Create a unidirection binding for thisProperty.voidbindBidirectional(Property<T> other) Create a bidirectional binding between thisPropertyand another one.booleanisBound()Can be used to check, if aPropertyis bound.voidunbind()Remove the unidirectional binding for thisProperty.voidunbindBidirectional(Property<T> other) Removes a bidirectional binding between thisPropertyand another one.Methods declared in interface Observable
addListener, removeListener, subscribeModifier and TypeMethodDescriptionvoidaddListener(InvalidationListener listener) Adds anInvalidationListenerwhich will be notified whenever theObservablebecomes invalid.voidremoveListener(InvalidationListener listener) Removes the given listener from the list of listeners, that are notified whenever the value of theObservablebecomes invalid.default SubscriptionCreates aSubscriptionon thisObservablewhich callsinvalidationSubscriberwhenever it becomes invalid.Methods declared in interface ObservableValue
addListener, flatMap, getValue, map, orElse, removeListener, subscribe, subscribe, whenModifier and TypeMethodDescriptionvoidaddListener(ChangeListener<? super T> listener) Adds aChangeListenerwhich will be notified whenever the value of theObservableValuechanges.default <U> ObservableValue<U> flatMap(Function<? super T, ? extends ObservableValue<? extends U>> mapper) Returns anObservableValuethat holds the value of anObservableValueproduced by applying the given mapping function on this value.getValue()Returns the current value of thisObservableValuedefault <U> ObservableValue<U> Returns anObservableValuethat holds the result of applying the given mapping function on this value.default ObservableValue<T> Returns anObservableValuethat holds this value, or the given constant if it isnull.voidremoveListener(ChangeListener<? super T> listener) Removes the given listener from the list of listeners that are notified whenever the value of theObservableValuechanges.default Subscriptionsubscribe(BiConsumer<? super T, ? super T> changeSubscriber) Creates aSubscriptionon thisObservableValuewhich calls the givenchangeSubscriberwith the old and new value whenever its value changes.default SubscriptionCreates aSubscriptionon thisObservableValuewhich immediately provides the current value to the givenvalueSubscriber, followed by any subsequent values whenever its value changes.default ObservableValue<T> when(ObservableValue<Boolean> condition) Returns anObservableValuethat holds this value and is updated only whenconditionholdstrue.Methods declared in interface ReadOnlyProperty
getBean, getName
-
Method Details
-
bind
Create a unidirection binding for thisProperty.Note that JavaFX has all the bind calls implemented through weak listeners. This means the bound property can be garbage collected and stopped from being updated.
- Parameters:
observable- The observable thisPropertyshould be bound to.- Throws:
NullPointerException- ifobservableisnull
-
unbind
void unbind()Remove the unidirectional binding for thisProperty. If thePropertyis not bound, calling this method has no effect.- See Also:
-
isBound
boolean isBound()Can be used to check, if aPropertyis bound.- Returns:
trueif thePropertyis bound,falseotherwise- See Also:
-
bindBidirectional
Create a bidirectional binding between thisPropertyand 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- the otherProperty- Throws:
NullPointerException- ifotherisnullIllegalArgumentException- ifotheristhis
-
unbindBidirectional
Removes a bidirectional binding between thisPropertyand 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- the otherProperty- Throws:
NullPointerException- ifotherisnullIllegalArgumentException- ifotheristhis
-