JavaFX controller is always null

前端 未结 2 1340
渐次进展
渐次进展 2021-01-22 11:47

I\'ll try to get in JavaFX 2 and used a simple demo app. The Project consists of 3 Files, the Main.java, the Controller.java and the sample.fxml.

In Sample.fxml i declare

2条回答
  •  失恋的感觉
    2021-01-22 12:13

    In addition to James_D's answer, I recommend to use the fx:root construct. Then you can inject the custom control (implemented by a controller) in another controller using the @FXML annotation.

提交回复
热议问题