簡體   English   中英

如何更改 javafx 警報框的圖標

[英]How to change the icon of a javafx alert box

如何在我的 javafx 應用程序中更改警報框的圖標。 我知道如何為我的主應用程序/階段本身執行此操作,但相同的方法不適用於警報。

javafx 中的警報示例

像這樣?

@Override
public void start(Stage stage) {
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Alert Test");
    alert.setHeaderText("Hello, world!");
    ImageView icon = new ImageView(new Image(String.valueOf(this.getClass().getResource("img/close-on.png"))));
    icon.setFitHeight(48);
    icon.setFitWidth(48);
    alert.getDialogPane().setGraphic(icon);
    alert.show();
}

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM