How to use FXMLLoader.load() - JavaFX 2

前端 未结 2 1509
不思量自难忘°
不思量自难忘° 2020-12-17 20:04

I am building a JavaFX application using the JavaFX Scene Builder. The interface was created in the Scene Builder and a FXML file (main.fxml) was created.

To use the

相关标签:
2条回答
  • 2020-12-17 20:37

    Try this

    Parent root= FXMLLoader.load(getClass().getResource("mention the path to your fxml file");
    

    hope that this would help

    0 讨论(0)
  • 2020-12-17 20:39

    Due to a variety of entities eligible to be loaded through FXML you need to state the expected type yourself.

    Parent page = FXMLLoader.<Parent>load(MainWindowController.class.getResource("main.fxml").toExternalForm());
    
    0 讨论(0)
提交回复
热议问题