Java ObjectProperty之间的双向绑定<;双倍>;双重属性
是否有任何内置函数可以在Java ObjectProperty之间的双向绑定<;双倍>;双重属性,java,javafx,binding,javafx-8,Java,Javafx,Binding,Javafx 8,是否有任何内置函数可以在DoubleProperty和ObjectProperty之间创建双向绑定 对于单向绑定,它非常容易: public void bindBidirectional(DoubleProperty doubleProperty, ObjectProperty<Double> doubleObjectProperty){ doubleProperty.bind(Bindings.createDoubleBinding(() -> doubleObjec
DoubleProperty
和ObjectProperty
之间创建双向绑定
对于单向绑定,它非常容易:
public void bindBidirectional(DoubleProperty doubleProperty, ObjectProperty<Double> doubleObjectProperty){
doubleProperty.bind(Bindings.createDoubleBinding(() -> doubleObjectProperty.get(), doubleObjectProperty));
}
public void bindProperty(DoubleProperty DoubleProperty,ObjectProperty doubleObjectProperty){
bind(Bindings.createDoubleBinding(()->doubleObjectProperty.get(),doubleObjectProperty));
}
但是由于Bindings.createDoubleBinging
返回Binding
,而不是Property
,因此我无法将其用于双向绑定。您可以这样做
doubleObjectProperty().bindBidirectional(doubleProperty.asObject());
谢谢,正是我想要的:)