JFrame 的 setIconImages() 方法使用哪些图标大小?

2022-01-24 00:00:00 frame icons size java jframe

有谁知道在 jFrame 的 setIconImages() (PLURAL) 方法中使用哪些图标大小,以便我的应用程序图标在所有平台和所有上下文中都能很好地显示(例如,窗口图标、任务栏图标、alt-tab 图标等)?

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

我找到了一个使用 16 像素 x 16 像素和 32 像素 x 32 像素图像的示例,但我需要更大吗?

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?

为了测试,我还尝试将 64px 和 128px 版本添加到传递给 setIconImages() 的列表中,但这些似乎没有在我的 Windows 7 机器上使用.但是,我无法在其他机器上轻松测试,所以想知道是否有人知道我应该包括哪些尺寸?

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?

推荐答案

根据 API,运行时从提供的列表中选择最合适的大小来使用.我会提供 16x1632x3264x64128x128 并让 JVM 在运行时决定.

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)

设置要显示为此窗口图标的图像序列.对 getIconImages 的后续调用将始终返回 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.

icons 列表从一开始就扫描最合适尺寸的图像.如果列表包含多个相同大小的图像,将使用第一个.

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.

没有指定图标的无主窗口使用 platfrom-default 图标.除非明确覆盖,否则拥有的窗口的图标可以从所有者那里继承.将图标设置为 null 或空列表会恢复默认行为.

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.

参数:

icons - 要显示的图标图像列表.

     icons - the list of icon images to be displayed.

自:

1.6

另请参阅:

getIconImages(), setIconImage(图像)

相关文章