Mac OS X上没有窗口的基于SystemTray的应用程序

如何在mac os x上执行仅作为SystemTray TrayIcon运行的应用程序(没有awt窗口和停靠图标)?

我正在使用的代码是这样的:

public class App { public static void main( String[] args ) { final TrayIcon trayIcon; if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); Image image = Toolkit.getDefaultToolkit().getImage("tray.gif"); trayIcon = new TrayIcon(image, "Tray Demo"); trayIcon.setImageAutoSize(true); try { tray.add(trayIcon); } catch (AWTException e) { System.err.println("TrayIcon could not be added."); } } else { System.out.println("Tray is not supported"); // System Tray is not supported } } } 

问题是我得到一个标题为com.cc.ew.App的停靠图标

要防止停靠中的图标,您必须在-Info.plist文件中添加布尔键LSUIElement并将其设置为YES。

 LSUIElement