向我的应用程序添加图标问题
我想更改我的应用程序的图标。 system.gif
位于当前目录中。 getDefaultToolkit()
不起作用。 getToolkit()
正在工作,但另一个最小化窗口也打开了。其他组件是Swing 组件。
Toolkit theKit = jtfMainFrame.getDefaultToolkit();
Image icon = theKit.getImage("system.gif");
I want to change the icon of my application. system.gif
is in current directory. getDefaultToolkit()
is not working. getToolkit()
is working but another minimized window is also open. Other components are Swing components.
Toolkit theKit = jtfMainFrame.getDefaultToolkit();
Image icon = theKit.getImage("system.gif");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
获取应用程序的图标。
ImageIO.read(URL)
。这是一种阻塞方法,可确保图像在继续之前完全加载。如果出现任何问题,它还会抛出信息异常。To get an icon for an app.
Class.getResource("/system.gif")
to obtain an URL to it. File objects will generally not work for such an 'application resource'.ImageIO.read(URL)
. This is a blocking method that will ensure the image is entirely loaded before proceeding. It will also throw informative exceptions if anything goes wrong.