WildOne (Yuri)
11/23/2020, 10:41 PMSamkeene
11/24/2020, 1:14 PMWildOne (Yuri)
11/24/2020, 5:57 PMWildOne (Yuri)
11/24/2020, 5:58 PMSamkeene
11/24/2020, 6:11 PMval myStringProperty = SimpleStringProperty()
button {
textProperty().bind(myStringProperty)
}
Samkeene
11/24/2020, 6:11 PMSamkeene
11/24/2020, 6:22 PMval myBoolProp = SimpleBooleanProperty()
button {
textProperty().bind(myBoolProp.stringBinding {
if (it == true) {
"button text 1"
} else {
"button text 2"
}
})
}
WildOne (Yuri)
11/24/2020, 6:36 PMif (radioController.isConnected()) isConnectedProperty.set(true)
WildOne (Yuri)
11/24/2020, 6:38 PMSamkeene
11/24/2020, 6:53 PMval buttonBinding = isConnectedProperty.stringBinding {
if (it == true) {
"Disconnect"
} else {
"Connect"
}
}
button {
textProperty().bind(buttonBinding)
}
I don't know too much about the inner working of javafx observables. When a value of an observable changes it fires a change event which you can listen in on. I would assume bind() is shorthand for attaching a listener to the property.Samkeene
11/24/2020, 6:59 PMSamkeene
11/24/2020, 6:59 PMbutton {
isConnectedProperty.onChange {
text = if (it) "disconnect" else "connect"
}
}