Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which icon sizes to use with a JFrame's setIconImages() method?

Does anyone know which icon sizes to use with the setIconImages() (PLURAL) method for a jFrame so that my app icons display well on all platforms and in all contexts (e.g., window icon, taskbar icon, alt-tab icon, etc.)?

I've found an example that uses a 16px-by-16px and a 32px-by-32px image, but do I need to go any bigger?

To test, I have also tried adding 64px and 128px versions to the List passed to setIconImages(), but these do not seem to be used on my Windows 7 machine. However, I cannot test easily on other machines, so am wondering if anyone knows which sizes I should include?

like image 878
ban-geoengineering Avatar asked Mar 06 '13 12:03

ban-geoengineering


1 Answers

According to the API the runtime chooses the most appropriate size to use from the list supplied. I would supply 16x16, 32x32, 64x64 and 128x128 and let the JVM decide at runtime.

public void setIconImages(List<? extendsImage> icons)

Sets the sequence of images to be displayed as the icon for this window. Subsequent calls to getIconImages will always return a copy of the icons list.

Depending on the platform capabilities one or several images of different dimensions will be used as the window's icon.

The icons list is scanned for the images of most appropriate dimensions from the beginning. If the list contains several images of the same size, the first will be used.

Ownerless windows with no icon specified use platfrom-default icon. The icon of an owned window may be inherited from the owner unless explicitly overridden. Setting the icon to null or empty list restores the default behavior.

Note : Native windowing systems may use different images of differing dimensions to represent a window, depending on the context (e.g. window decoration, window list, taskbar, etc.). They could also use just a single image for all contexts or no image at all.

Parameters:

     icons - the list of icon images to be displayed.

Since:

     1.6

See Also:

     getIconImages(), setIconImage(Image)

like image 183
Alan Sergeant Avatar answered Sep 28 '22 20:09

Alan Sergeant