JavaFX 8 default message icons

2019-06-13 04:03发布

问题:

with the last few updates of JavaFX we have alerts. I want to get the message's default icons (error, warning, ...). In Swing, I can get the L&F message icons through some UIManager's properties. How can I get the message's default icons in JavaFX? Are them contained in properties, or defined by CSS class?

Thanks in advance.

回答1:

They are defined in modena.css as

.alert.confirmation.dialog-pane,
.text-input-dialog.dialog-pane,
.choice-dialog.dialog-pane {
    -fx-graphic: url("dialog-confirm.png");
}

.alert.information.dialog-pane {
    -fx-graphic: url("dialog-information.png");
}

.alert.error.dialog-pane {
    -fx-graphic: url("dialog-error.png");
}

.alert.warning.dialog-pane {
    -fx-graphic: url("dialog-warning.png");
}

You can override them in a regular way.