I\'m trying to add an external icon from an *.ico file to a window that I\'m creating using the WindowBuilder design window. I can select the shell, which brings up an \"image\"
I don't know how to do this in WindowBuilder, but you can specify an Image
resource while building the Shell
via setImage()
or setImages()
. I suggest using the latter, because it provides the platform with various resolution icons, including the window's control box, the Windows taskbar, and alt+tab list.
Take a look at this snippet.
To load it from a resource:
final Image small = new Image(shell.getDisplay(),
"resources/images/icon_16.png");
final Image large = new Image(shell.getDisplay(),
"resources/images/icon_32.png");
final Image[] images = new Image[] { small, large };
shell.setImages(images);
In this example, I have a subfolder "resources", containing "images", then two PNGs. Specifying a resource JAR should work in a similar way, although I haven't tried it.