FXML Load exception

。_饼干妹妹 提交于 2019-12-01 03:27:08
Ayoub

The problem is in source

So, you've got to change it to a proper one

So do that, edit the source of the fxml file here

AnchorPane root = (AnchorPane) FXMLLoader.load(Main.class.getResource("LoginGUI.fxml"));

with this one

AnchorPane root = (AnchorPane) FXMLLoader.load(Main.class.getResource("/packagename/LoginGUI.fxml"));

I experienced this issue too. I found that I did not add the package name to the controller name given in the FXML file; I initially just added the Controller class name. For example: if my controller class is under com.stackoverflow.gui package and the name of my controller class is LoginController. The FXML file should have com.stackoverflow.gui.LoginController and not just LoginController

I had the same problem today and for those who may have it and (like me) are looking for an answer for that:

You may have changed any component Id on your Controller file and forgot to update the Id on sceneBuilder (or FXML file)[or Vice-Versa], so the Controller can't link the component on View file.

For Exemple: (On Controller file)

@FXML
Button btnName1

(On FXML file or SceneBuilder)

fx:id="btnName_1"

:-)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!