Java Mac OS X上基于SystemTray的无窗口应用程序
如何在mac os x上运行一个仅作为SystemTrayIcon运行的应用程序(没有awt窗口和dock图标) 我使用的代码是:Java Mac OS X上基于SystemTray的无窗口应用程序,java,macos,user-interface,awt,trayicon,Java,Macos,User Interface,Awt,Trayicon,如何在mac os x上运行一个仅作为SystemTrayIcon运行的应用程序(没有awt窗口和dock图标) 我使用的代码是: public class App { public static void main( String[] args ) { final TrayIcon trayIcon; if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray()
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的dock图标要防止图标出现在dock中,你必须在
-Info.plist
文件中添加布尔键并将其设置为YES
<key>LSUIElement</key>
<true/>
LSUIElement
要防止图标进入dock,必须在-Info.plist
文件中添加布尔键并将其设置为YES
<key>LSUIElement</key>
<true/>
LSUIElement
您的问题是什么?怎么了?我在码头上有trayicon和java应用程序,而不仅仅是trayicon。我会编辑问题并澄清你的问题是什么?怎么了?我在码头上有trayicon和java应用程序,而不仅仅是trayicon。我将编辑问题并澄清是的,这是标准的macos惯例。所有的应用程序都是一样的。是的,这是标准的macos惯例。所有的应用程序都是这样做的。