JavaFX application still running after close

后端 未结 8 1207
长发绾君心
长发绾君心 2021-01-04 00:25

I\'m having problem to close my javaFX application, when I click the close button from my stage, my application disappears but if I look for it in my task manager my applica

8条回答
  •  感情败类
    2021-01-04 01:14

    You could close your application by clicking close Button , with some code.

          stage.setOnCloseRequest(
                    event -> closeMyApp()                   
            );
          private void closeMyApp()
           {
             try
                {
                Stage stage = (Stage) closeButton.getScene().getWindow();
                stage.close();
                }
              catch(Exception ee)
                  {
                   ex.printStackTrace();
                   }
          }
        // where closeButton is button having similar controller class initialization.
               @FXML
               private Button closeButton;
    

提交回复
热议问题