Issue
I started working with JavaFx and the SceneBuilder 5 days ago. I have one question. Under the label "code" I have the fx:id (Am I right, that this is the method-name) and the field on-Action. What's the sense of the on-Action-field?
Thanks for your help :-)
Best regards,
Michael
Solution
The On Action field is the name of the event listener method for actionable components. For example, add a button and add the name buttonOnAction to the field On Action. Now go to the menu View -> Show Sample Controller Skeleton. You should see this snippet:
@FXML
void buttonOnAction(ActionEvent event) {
}
This method must also be the mentioned by name in the fxml file of course, which should have an entry like this:
<Button onAction="#buttonOnAction" text="Button" />
Therefore, clicking that button fires the method buttonOnAction.
Answered By - mohsenmadi