修改我的.jar程序的任务栏图标 [英] Modifying taskbar icon of my .jar program

查看:220
本文介绍了修改我的.jar程序的任务栏图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次运行.jar程序时,我都会尝试更改任务栏中显示的默认java图标。我设法用frame.setIconImage(img)更改它;但这使得图标太小,我希望它与其他程序图标一样大,并且具有高质量。我能以任何方式做到这一点吗?谢谢。

I'm trying to change the default java icon that appears in taskbar everytime I run my .jar program. I managed to change it with frame.setIconImage(img); but this makes icon way too small, I want it to be as big as other programs icons and have a high quality. Any way I can do that? Thanks.

推荐答案

由于您只提供了单个图标,因此Windows将 scale 该图标为任何需要在任务栏中显示的大小(可以是16x16,32x32或其他大小,具体取决于桌面和任务栏的大小。

As you only supplied a single icon, Windows will then scale that icon to whatever size it needs displaying it in the taskbar (could be 16x16, 32x32 or other sizes, depending on the desktop them and size of the taskbar.

如果你想在任务栏中有一个漂亮的图标,你需要提供一个32x32像素的图标版本。

If you want to have a "good looking" icon in the task bar you will need to provide a 32x32 pixel version of your icon.

一旦你有了这个,你可以致电 setIconImages (列表) 而不是 setIconImage()来定义操作系统可以使用的图标:

Once you have that you can call setIconImages(List) instead of setIconImage() to define the icons that the operating system can use:

List<Image> icons = new ArrayList<Image>();
icons.add(getImage("someImage16x16.gif"));
icons.add(getImage("someImage32x32.gif"));
window.setIconImages(icons);

其中 getImage()是返回正确图像图标的方法。基本上,这与您用于定义当前图标的步骤相同。

Where getImage() is some method returning the proper image icon. Essentially that would be the same steps you already used to define the current icon.

您还可以使用此方法提供64x64和24x24图标(只需向图标添加更多图标)列表)。

You can also supply a 64x64 and 24x24 icon using this method (just add more icons to the list).

这篇关于修改我的.jar程序的任务栏图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆