JavaFx-when fxml inject object field?

后端 未结 2 1855
我在风中等你
我在风中等你 2021-01-26 05:52

I\'m new to javaFx,and I have found only within the @fxml function and initialize function the @fxml field not be null otherwise the @fxml field will always be null,is it true?

2条回答
  •  花落未央
    2021-01-26 06:17

    You can specify the controller in the FXML file. The FXMLLoader will initialize the variables in the controller. In that case there is not problem with your code. It is good practice to separate the controller from the main class.

提交回复
热议问题