How do I add an icon as a classpath resource to an SWT window created with WindowBuilder?

Zoot picture Zoot · Dec 23, 2010 · Viewed 32.3k times · Source

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" properties field. alt text That brings up the image chooser dialog box: alt text

How do I make my icon show up in this menu as a classpath resource? The image works if an absolute path is given, but I don't want to use that option in my application.

Thanks!

Answer

Zoot picture Zoot · Jan 3, 2011

To easily add an icon to my classpath, I found my desired icon, right clicked it, selected "copy", then went to one of the packages of my project in Eclipse, right clicked, and selected "paste". The next time I brought up the image chooser dialog box, my local package had the icon listed as an available classpath resource, and I chose it. image chooser

I was able to export the project to a runnable JAR, and the icon still worked.