When I bidirectionally bind two properties in JavaFx, which start out with different values, which gets taken?
ObjectProperty<MyType> property1 = new SimpleObjectProperty(value1);
ObjectProperty<MyType> property2 = new SimpleObjectProperty(value2);
property1.bindBidirectional(property2);
// will both properties be set to value1 or to value2?
In my tests (slightly different setup), property2
seems to be set to the value of property1
. However, is this a coincidence or is this behavior that I can depend on? I did not find anything about this in the API.
Because I can't be sure, I currently use the following pattern, but this seems redundant to me:
ObjectProperty<MyType> property1 = new SimpleObjectProperty(value1);
ObjectProperty<MyType> property2 = new SimpleObjectProperty(value2);
property1.setValue(property2.getValue());
property1.bindBidirectional(property2);