如何在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
的停靠图标答案 0 :(得分:4)
要阻止停靠栏中的图标,您必须在<your-app>-Info.plist
文件中添加布尔键LSUIElement
并将其设置为YES。
<key>LSUIElement</key>
<true/>