javafx.scene.control.Dialog won't close on pressing “x”

前端 未结 5 1046
傲寒
傲寒 2020-12-06 17:36

If I just create an empty class extending from javafx.scene.control.Dialog, it won\'t close when I\'m pressing the \"x\" button in the top right corner

5条回答
  •  误落风尘
    2020-12-06 18:32

    I have faced this situation with alerts with the below code.

    Alert alert = new Alert(Alert.AlertType.NONE);
         alert.setTitle("Export Successful");
         alert.setContentText("All the posts have been exported to Posts.txt file 
     successfully");
        alert.show(); 
    

    The only workaround would be to create an alert or dialog with a button in it like below.

    Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Export Successful");
        alert.setContentText("All the posts have been exported to Posts.txt file 
    successfully");
        alert.showAndWait();
    

提交回复
热议问题