Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modifying taskbar icon of my .jar program

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.

like image 352
Rohit Malish Avatar asked May 13 '12 21:05

Rohit Malish


People also ask

How do I change the taskbar icon for a program?

Alternatively, if you hold Shift and right-click the icon on the taskbar, you get the standard Windows Explorer context menu, instead of the application jump list. Again, click Properties. From the Properties dialog, go to the Shortcut tab and click the Change Icon button. Select a new icon file by clicking Browse.

How do I pin a jar file to the taskbar in Windows 10?

Once you move the jar file right click/properties and find Target: at the very beginning of the Line add C:\Windows\explorer.exe this will add the jar file to the list of Recently added Programs (Win10 thinks you "install" this Program) now you can added to the taskbar or the start menu shortcuts.


2 Answers

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

like image 166
a_horse_with_no_name Avatar answered Oct 18 '22 00:10

a_horse_with_no_name


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

like image 26
kentcdodds Avatar answered Oct 18 '22 00:10

kentcdodds