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

标签 java icons size jframe frame

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

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

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

最佳答案

根据 API,运行时从提供的列表中选择最合适的大小来使用。我会供应 16x16 , 32x32 , 64x64128x128让 JVM 在运行时决定。

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)

关于java - JFrame 的 setIconImages() 方法使用哪些图标大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15247653/

相关文章:

c - 全局变量如何影响可执行文件的大小?

WPF:如何以原始尺寸显示图像?

java - 处理与 Jackson `JsonIgnoreProperties` 的 JPA/Hibernate 实体双向关系的循环引用/依赖关系时出错

java - 覆盖从构造函数调用的方法

visual-studio - Visual Studio安装程序项目: Installer and Application Icons

html - 使用图标字体的替代方法

html - 如何使 div/video 始终为浏览器窗口的大小,并固定在特定位置

java - 如何为列表中的类的所有实例调用方法?

java - 通过 spring 表单操作传递的 URI 错误

user-interface - .ico 的理想大小