Witam, napisałem program, który tworzy mi nowy Stage. Z tego co widzę w internecie są na to 2 sposoby i nie wiem czemu jeden mi nie działa :
private void newWindow(String fxmlPath, Emp user, int type) throws IOException {
//Parent root = FXMLLoader.load(getClass().getClassLoader().getResource(fxmlPath));
FXMLLoader loader = new FXMLLoader(getClass().getResource(fxmlPath));
Parent root = (Parent) loader.load();
Stage stage = new Stage();
stage.setTitle("Klient");
stage.setScene(new Scene(root));
stage.show();
}
Konkretnie działa mi ten, który jest w komentarzu, a ten 2 daje taki błąd :
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
.
.
.
Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at sample.Controllers.LoginController.newWindow(LoginController.java:72)
at sample.Controllers.LoginController.logIn(LoginController.java:57)
... 58 more