Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Reload Java Fx Scene?

I want to reload my Scene of the Java Fx project.

So i created a button, which has an Fx-ID

now i want to create something, that reloads the whole fx scene after pressing the button…

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How is this possible.?

@Override
public void start(Stage stage) throws IOException {
    FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));

    Scene scene = new Scene(fxmlLoader.load());
    stage.setTitle("!");
    stage.setScene(scene);
    stage

this is my scene

>Solution :

Try

Stage close = (Stage) restart.getScene().getWindow();
    close.close();
    Stage stage = new Stage();
    FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));

    Scene scene = new Scene(fxmlLoader.load());
    stage.setTitle("!");
    stage.setScene(scene);
    stage.show();
}

this should help to close your stage. you will also create another stage, with deleted inputs

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading