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

前端 未结 5 1031
傲寒
傲寒 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:14

    In my Dialog I'm using what @vbargl said:

    Window window = alert.getDialogPane().getScene().getWindow();
    window.setOnCloseRequest(event -> window.hide());
    

    It closes the dialog, but it's bringing me a no value present error.

    To avoid it, I'm also checking result.get() and that result.isPresent().

提交回复
热议问题