JDialog - 如何更改图标 [英] JDialog - how to change icon
本文介绍了JDialog - 如何更改图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更改 JDialog 的图标(替换标准的 java 杯)我可以这样做:
I want to change icon of the JDialog (to replace standard java cup) I am able to do that this way:
ImageIcon img = new ImageIcon(OuterClass.class.getResource("fileThatWorks.jpg"));
myJDialog.setIconImage(img.getImage());
然而,当我用 image.ico
替换 fileThatWorks.jpg
时,代码停止工作.我试图将我的 image.ico
转换为 image.jpg
但它没有 nelped.
Howerver when I replaced fileThatWorks.jpg
with image.ico
code stopped working.
I've tried to convert my image.ico
to image.jpg
but it didn't nelped.
我的方法有什么问题?为什么它适用于某些 *jpg 文件但不适用于 *ico 文件?
What's wrong with my approach? Why it works for some *jpg files but doesn't work for *ico files?
推荐答案
ImageIcon API 声明支持的类型是 JPEG &动图.不太确定是否有解决方法.
The ImageIcon API states that the supported types are JPEG & GIF. Not too sure of a workaround for that.
这篇关于JDialog - 如何更改图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文