Bindings helper function

The Bindings class has a helper function for custom bindings:

// chapter3.other.CreateBinding.java
Bindings.createObjectBinding(
()-> btn.isPressed() ? Color.RED : Color.GREEN, // computeValue logic
btn.pressedProperty() // list of observed values
);

And, as a small reminder, let's rewrite this binding once again using the Boolean binding operations we reviewed in the preceding code:

scene.fillProperty().bind(
Bindings.when(btn.pressedProperty())
.then(Color.RED)
.otherwise(Color.GREEN));
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.255.187