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

后端 未结 6 1859
忘掉有多难
忘掉有多难 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条回答
  •  萌比男神i
    2020-12-05 19:01

    Use

    stage.hide()
    

    If you do this from a controller, you can get the stage from any Node inside the scene of the stage (if necessary let the FXML loader assign one to a field of the controller using the id attribute from the fxml namespace in the fxml):

    Window stage = node.getScene().getWindow();
    

提交回复
热议问题