2

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?

enter image description here

Thanks in advance.

Alberto
  • 1,569
  • 1
  • 22
  • 41

2 Answers2

6

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.

Uluk Biy
  • 48,655
  • 13
  • 146
  • 153
  • Example source: https://github.com/openjdk/jfx/blob/master/modules/javafx.controls/src/main/resources/com/sun/javafx/scene/control/skin/modena/modena.css – AgainPsychoX Jun 30 '23 at 22:23
0
.dialog-pane{
    -fx-graphic: url(the url of your icon) ;
}

To hide definitely the icon, put

-fx-graphic: null;