How do I change the icon of the alert box of in my javafx application. I know how to do it for my main application/stage itself but the same method doesn't work for the alert.
like this?
@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();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.