Mateusz Dryzek
Mateusz Dryzek

Reputation: 661

Bidirectional binding between ObjectProperty<Double> and DoubleProperty

Is there any built-in function to create a bidirectional binding between DoubleProperty and ObjectProperty<Double>?

For one direction binding it is pretty easy :

public void bindBidirectional(DoubleProperty doubleProperty, ObjectProperty<Double> doubleObjectProperty){
    doubleProperty.bind(Bindings.createDoubleBinding(() -> doubleObjectProperty.get(), doubleObjectProperty));
}

but since Bindings.createDoubleBinging returns Binding, not Property I can't use it for bidirectional binding.

Upvotes: 3

Views: 1051

Answers (1)

James_D
James_D

Reputation: 209673

You can do

doubleObjectProperty().bindBidirectional(doubleProperty.asObject());

Upvotes: 5

Related Questions