不,根据javadoc不接受关闭请求:既没有一个也没有多个按钮。
你可以指定一个
ButtonType
因此
Alert
关好。
Alert simpleAlert = new Alert(Alert.AlertType.NONE);
simpleAlert.setContentText("Testing");
simpleAlert.initStyle(StageStyle.UNDECORATED);
simpleAlert.show();
new Thread(() -> {
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
}
Platform.runLater(() -> {
simpleAlert.setResult(ButtonType.CANCEL);
simpleAlert.close();
});
}).start();