how to locate fxml from another package?

后端 未结 3 468
傲寒
傲寒 2020-12-31 12:43

I have created a simple JavaFX application.

\"enter

It has two pa

相关标签:
3条回答
  • 2020-12-31 12:52

    Try

    Parent root = FXMLLoader.load(getClass().getResource("/jfxtest2/Screen.fxml"));
    
    0 讨论(0)
  • 2020-12-31 12:54

    You need to use

    getClass().getClassLoader().getResource("/jfxtest2/Screen.fxml")
    
    0 讨论(0)
  • 2020-12-31 13:06

    For me nothing worked besides this:

    Parent root = FXMLLoader.load(getClass().getResource("..//jfxtest2//Screen.fxml"));
    
    0 讨论(0)
提交回复
热议问题