According to the JavaFX tutorial it should be possible to register event handlers to observable properties in FXML:
Any class that defines a setOnEvent() method can be assigned an event handler in markup, as can any observable property (via an "onPropertyChange" attribute).
Now, I'm trying to register an event handler for the selected property of ToggleButton:
<ToggleButton text="%SomePane.fooButton.text" onSelectedChanged="#handleFooSelectedChanged" toggleGroup="$toggleGroup"/>
and in the controller:
@FXML
public void handleFooSelectedChanged(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
}
But I'm getting the following error:
Caused by: javafx.fxml.LoadException: Controller method "handleFooSelectedChanged" not found.
Do I have to change the method signature? Is this a bug? Or is this not supported at all?