Adding an icon to a form dialog


I created a Dialog and changed the text. Now I am trying to change the icon in the header of the dialog.

So far I tried:

public CreateDialog() {
// set Title for dialog
this.setTitle("Create Class");
// set Image for dialog. Also tried .ico file
URL iconURL = getClass().getResource("/icons/logo.svg");
ImageIcon icon = new ImageIcon(iconURL);
// tried both
// this.setIconImage(icon.getImage());

It always shows the red-blue IntelliJ icon.
When I am trying dialog.setIconImage nothing happens.
When I try dialog.getOwner().setIconImage I getting the full black IntelliJ icon, but still not mine.

评论操作 固定链接

Please use DialogWrapper for showing dialogs in IDE There is no possibility to set custom icon for modal dialog.