如何将图标作为类路径资源添加到使用WindowBuilder创建的SWT窗口? [英] How do I add an icon as a classpath resource to an SWT window created with WindowBuilder?
问题描述
我正在尝试从* .ico文件添加一个外部图标到我正在使用WindowBuilder设计窗口创建的窗口。
我可以选择外壳,这会弹出一个图像属性字段。
打开图像选择器对话框:
< img src =https://i.stack.imgur.com/abOpe.pngalt =alt text>
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. That brings up the image chooser dialog box:
如何让我的图标显示在这个菜单中作为一个类路径资源?如果给出绝对路径,该图像将会起作用,但我不想在我的应用程序中使用该选项。
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.
谢谢!
推荐答案
为了轻松添加一个图标到我的课程路径,我找到了我想要的图标,右键点击它,选择复制,然后去了我的项目的一个包在Eclipse中,右键单击并选择粘贴。
下次我提出了图像选择器对话框时,我的本地包将图标列为可用的类路径资源,我选择了它。
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.
我能够将项目导出到可运行的JAR,图标仍然有效。
I was able to export the project to a runnable JAR, and the icon still worked.
这篇关于如何将图标作为类路径资源添加到使用WindowBuilder创建的SWT窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!