![](/img/trans.png)
[英]How to hide the Java SWT program icon in the Dock when the application is in the tray
[英]How to set a high quality OSX dock icon for an SWT Java application
我编写了一个 SWT Java 应用程序,并希望将其配置为在 OSX 扩展坞中使用高质量图标。 这是我当前的代码:
// Prepare window
final Shell window = new Shell();
// Load icons
Display display = window.getDisplay();
ClassLoader loader = InTraceStandaloneUI.class.getClassLoader();
InputStream is16 = loader.getResourceAsStream(
"org/intrace/icons/intrace16.gif");
Image icon16 = new Image(display, is16);
is16.close();
InputStream is32 = loader.getResourceAsStream(
"org/intrace/icons/intrace32.gif");
Image icon32 = new Image(display, is32);
is32.close();
window.setImages(new Image[] {icon16, icon32});
这适用于加载在 Windows 上看起来不错的 16x16 和 32x32 徽标,但 OSX 使用的徽标仍然看起来很像素化。 我只需要指定更高分辨率的第三个版本,还是应该使用不同的图像格式或 API?
实际上,如果您调用 Shell.setImages(...) 并包含一个 128x128 图标,那么 OSX 将选择它,您将获得一个高质量的停靠图标,而无需使用 Apple 扩展类。
您可以检测 OSX 并使用 Apple Java Extensions 并调用Application.setDockIconImage(...)
不应该在 Info.plist 中使用
<key>CFBundleIconFile</key>
<string>icon.icns</string>
线?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.