How to close a java window with a button click - JavaFX Project

后端 未结 6 1862
忘掉有多难
忘掉有多难 2020-12-05 18:26

I made a JavaFX project and created the GUI for the first-login frame in the java Scene Builder. When the login is successful, the login frame must be closed and the next fr

6条回答
  •  天命终不由人
    2020-12-05 19:07

    Hide doesn't close the window, just put in visible mode. The best solution was:

    @FXML
    private void exitButtonOnAction(ActionEvent event){
            ((Stage)(((Button)event.getSource()).getScene().getWindow())).close();      
    }
    

提交回复
热议问题