【发布时间】:2011-02-20 14:36:43
【问题描述】:
如何在 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 的停靠图标
【问题讨论】:
-
你的问题是什么?怎么了?
-
我在扩展坞上有一个托盘图标和一个 Java 应用程序,而不仅仅是托盘图标。我将编辑问题并澄清
标签: java macos user-interface awt trayicon