Modifying taskbar icon of my .jar program

佐手、 提交于 2020-01-01 04:17:55

问题


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.


回答1:


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.

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.

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);

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.

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




回答2:


Try looking at this example. It looks like you need to use frame.setIconImage(Toolkit.getDefaultToolkit().getImage("your_image.gif")); line



来源:https://stackoverflow.com/questions/10575541/modifying-taskbar-icon-of-my-jar-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!