I am currently working with two controller classes.
In Controller1, he creates a new stage that opens on top of the main one.
Stage stage = new Stage(); Parent root = FXMLLoader.load(getClass().getResource("Controller2.fxml")); Scene scene = new Scene(root); stage.setScene(scene); stage.show();
Now that this stage is open, I want it to remain open for about 5 seconds before closing.
Inside Controller2, I tried to implement something like
long mTime = System.currentTimeMillis(); long end = mTime + 5000; // 5 seconds while (System.currentTimeMillis() > end) { //close this stage }
but I have no idea what to put inside the while loop to close it. I tried all kinds and nothing works.
source share