简体   繁体   English

JavaFx .Fxml及其控制器类

[英]JavaFx .Fxml and its controller class

.fxml文件及其对应的控制器类之间的关系如何解释

To put it simply, the .fxml file defines what all UI elements are required and how their heirarchy should be built. 简而言之,.fxml文件定义了所有UI元素都需要什么以及如何构建它们的层次结构。 It also defines the actions to be performed when some user event occurs on these UI elements. 它还定义了在这些UI元素上发生某些用户事件时要执行的操作。

During runtime, the UI components generated by JavaFX are injected as instance variables in the controller. 在运行时,由JavaFX生成的UI组件将作为实例变量注入到控制器中。 And callbacks from the UI elements are routed to methods in the controller. UI元素的回调将路由到控制器中的方法。

Refer: 参考:

  1. https://docs.oracle.com/javafx/2/fxml_get_started/fxml_tutorial_intermediate.htm#CACFEHBI https://docs.oracle.com/javafx/2/fxml_get_started/fxml_tutorial_intermediate.htm#CACFEHBI
  2. https://docs.oracle.com/javafx/2/get_started/fxml_tutorial.htm https://docs.oracle.com/javafx/2/get_started/fxml_tutorial.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM