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

后端 未结 6 1875
忘掉有多难
忘掉有多难 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:00

    Thanks for your time to reply,but in the end I found out how to fix it. I used

    ((Node)(event.getSource())).getScene().getWindow().hide();
    

    in the if that it's responsible for the successful login. I mean, after a dialog appears that informs the user about their successful login, that code goes there.

    (I imported the right stuff too in order to make that line of code work)

提交回复
热议问题