vendredi 23 juin 2017

JavaFX hide function not working

I'm coding in JavaFX and I have a basic Checkbox widget on my first FXML document that goes to a handle method which shows and hides a second window when checked and unchecked in an if-statement. It shows the window when checked... but doesn't hide when unchecked. Can anyone explain why?

public void show() throws IOException{
        Stage second = new Stage();
        FXMLLoader loader = new 
            FXMLLoader(Main.class.getResource("second.fxml"));
        AnchorPane root = loader.load();

        Scene scene = new Scene (root);
        second.setScene(scene);
        second.setX(50); second.setY(50);

        if (check.isSelected()){second.show();}
        else{second.hide();}
    }




Aucun commentaire:

Enregistrer un commentaire