删除默认的 JFrame 图标
在我的 JFrame 中,我有默认的咖啡图标。我想删除它。但是当我执行 setIconImage(null) 时它不起作用。谁能告诉我如何彻底删除图标的解决方案
In my JFrame i have the default coffee icon. I want to remove it. But when i do setIconImage(null) it does't work. Can anyone tell me the solution as to how to completely remove the icon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
最好保留一份 Java 源代码。 java.awt.Window(JFrame 的超类)的代码具有以下
setIconImage
代码:您可以看到,传入空图像与不执行任何操作相同,因此您必须传递在图像中摆脱咖啡杯。正如其他人建议的那样,使用 1 x 1 透明图标是最好的选择。这是创建图标的一些代码:
It's always good to keep a copy of the Java source code around. The code for java.awt.Window (a superclass of JFrame) has the following code for
setIconImage
:You can see that passing in a null image is the same as doing nothing so you'll have to pass in an image to get rid of the coffee cup. As others have suggested using a 1 x 1 transparent icon is your best bet. Here is some code to create the icon:
创建由一个像素组成的图标(透明性更好)并使用它。如果您需要这样的图标请联系我。我会寄给你。
Create icon that consists of one pixel (better transparent) and use it. If you need such icon contact me. I will send you.
您可以将图像图标设置为透明图像,这将移除咖啡杯。我认为否则不可能摆脱默认图标。
You can set the image icon to a transparent image which will remove the coffee cup. I don't believe it is possible to get rid of the default icon otherwise.
您可以只使用 gimp 或 Photoshop,甚至绘画并创建 1x1px 的透明图像,然后将其导出(.png 或 .jpg,没关系?)。
然后应用它:
应该没问题。
You could just use gimp or photoshop or even paint and create a 1x1px, transparent image, export it (.png or .jpg, doesnt matter?).
Then apply it:
Should be fine.