我5天前开始使用JavaFx和SceneBuilder . 我有一个问题 . 在“代码”标签下,我有fx:id(我是对的,这是方法名称)和字段on-Action . 什么是on-Action-field的意义?
谢谢你的帮助 :-)
最好的祝福,
迈克尔
On Action 字段是可操作组件的事件侦听器方法的名称 . 例如,添加一个按钮并将名称buttonOnAction添加到字段 On Action . 现在进入菜单View - > Show Sample Controller Skeleton . 你应该看到这个片段:
@FXML void buttonOnAction(ActionEvent event) { }
此方法当然也必须在fxml文件中通过名称提及,该文件应具有如下条目:
<Button onAction="#buttonOnAction" text="Button" />
因此,单击该按钮将触发方法bottonOnAction .
1 回答
On Action 字段是可操作组件的事件侦听器方法的名称 . 例如,添加一个按钮并将名称buttonOnAction添加到字段 On Action . 现在进入菜单View - > Show Sample Controller Skeleton . 你应该看到这个片段:
此方法当然也必须在fxml文件中通过名称提及,该文件应具有如下条目:
因此,单击该按钮将触发方法bottonOnAction .