public static void callNewScene(String sceneJump, Event event) throws IOException {
((Node)event.getSource()).getScene().getWindow().hide();
Stage primaryStage = new Stage();
FXMLLoader loader = new FXMLLoader();
Pane root = loader.load(getClass().getResource(sceneJump).openStream());
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
I have this method that will hide current scene and show a new scene afterwards. But its giving me an error on this "getClass()." It doesn't seem recognize it. How can i fix this,? Please help. It is working if i put this directly on my controller but i dont want my code to be redundant.
Picture Example:
Or if you guys a better way Where i can make hide/open a new scene as I've said above please feel free to suggest thank you but its important to be method that pass a value.