Exception in Application start method java.lang.reflect.InvocationTargetException

前端 未结 10 1760
刺人心
刺人心 2021-01-02 18:47

I am just starting out with JavaFX, and I am trying to build a simple application with a label, text field and button which, when clicked, sets the label\'s value to that of

10条回答
  •  执笔经年
    2021-01-02 19:31

    For anyone who has this exact same problem in the future, as James_D and the other answer contributors mentioned, removing the "/" at the beginning of the path fixes the problem so use

    FXMLLoader loader = new FXMLLoader(Main.class.getResource("MainWindowView.fxml"));
    

    instead of

    FXMLLoader loader = new FXMLLoader(Main.class.getResource("/MainWindowView.fxml"));
    

提交回复
热议问题