Annotating fields with the @FXML annotation.
The fx:id attribute is a unique identifier of a UI element in FXML that allows the component to be accessed from the controller. The variable name in the controller must match the fx:id. Fields annotated with @FXML will be automatically initialized.
Example:
| FXML | Java |
| |
Annotating methods with the @FXML annotation.
Action method – Event handlers
The attributes onAction, onMouseClicked, etc., connect an FXML event to a method in the Controller. The method must exist in the controller, be annotated with @FXML, and have a void return type.
| FXML | Java |
| |