Which icon sizes to use with a JFrame's setIco

2019-01-19 10:55发布

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?

1条回答
Evening l夕情丶
2楼-- · 2019-01-19 11:24

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 voidsetIconImages(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)

查看更多
登录 后发表回答