Property-to-Property Bindings
Lines 31–38 set up property bindings between a Slider’s value and the corresponding TextField’s text so that changing a Slider updates the corresponding TextField. Consider lines 31–32, which bind the redSlider’s valueProperty to the redTextField's textProperty:
redTextField.textProperty().bind( redSlider.valueProperty().asString("%.0f"));
Each TextField has a text property that’s returned by its textProperty method as StringProperty (package javafx.beans.property). StringProperty method bind receives an ObservableValue as an argument. When the ObservableValue changes, the bound property is updated accordingly. In this case the ObservableValue is the result of the expression redSlider.valueProperty().asString("%.0f") ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access