I came across some very strange behaviour a couple of times every time forgetting the trick.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("view/window.fxml"));
Parent root = loader.load();
GuiController controller = loader.getController();
Now the controller is not null.
However, after I do this...
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("view/window.fxml"));
Parent root = loader.load(getClass().getResource("view/window.fxml"));
GuiController controller = loader.getController();
The controller is now null.
I understand that the loader somehow looses his grip on location? I would very much appreciate somebody telling me that this is an expected behaviour and explain me why.
Please note that is looked quite a bit after post concerning this problem found nothing, and discovered the solution only after 2h of experimentation, so please don't link me up with similar looking questions.
loader, notfxmlLoaderin both calls tosetLocation(...).