来自资源中图像的SetIconImage [英] SetIconImage from Images in the resource
问题描述
我有一个Swing应用程序,该应用程序的资源中有一个图像文件夹。我使用以下代码访问图像:
I have A swing Application that has an Image Folder in the resources. I use the Following Piece of code to access the Images:
btnDel = new JButton(new ImageIcon(getClass().getResource("/Recycling-Pool.png")));
此方法对我来说很好,例如JLabels和JMenuItems等组件的图像。我有一个应用程序图标,可以使用以下代码进行访问:
This Methods Works fine For me in reference to Images for Components such as JLabels and JMenuItems. I have an Icon for the Application which I access using the Following Code:
setIconImage(getToolkit().getImage("Images/Free bsd.gif"));
这对Bar Icon也很好用,但是我希望图标也与Aplilication捆绑在一起我不知道如何访问应用程序栏的图标图像。
This Also works fine for the Bar Icon, But I want the Icon Also Bundled together With the Apllication and I can't figure Out How to access the Icon Image for the Application Bar. Please Help.
推荐答案
我想出了答案。很抱歉浪费您的时间。就像这样:
I figured Out the Answer. Sorry for Wasting your time. It will be like this:
setIconImage(getToolkit().getImage(getClass().getResource("/Free bsd.gif")));
对于嵌入式图像,这对我来说效果很好。 :)
This works fine for me for an embedded Image. :)
这篇关于来自资源中图像的SetIconImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!