How to change the scene itself in the class controller. After all, the Stage is created in the main class, and I can not reach it. main class:
@Override public void start (Stage primaryStage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("/login.fxml")); Scene scene = new Scene(root); primaryStage = new Stage(); primaryStage.setScene(scene); primaryStage.show(); } Controller class:
@FXML private void pressRegistration() { try { Parent root = FXMLLoader.load(getClass().getResource("/registration.fxml")); Scene scene = new Scene(root); Stage primaryStage = new Stage(); primaryStage.setScene(scene); primaryStage.show(); } catch (IOException e) { e.printStackTrace(); } } By clicking on the button, another window is created ( Stage ). How do you get to the current Stage (which is in main ), and call the setScene() method?