- 论坛徽章:
- 0
|
楼上的好像不行,可以试下这样
TrayIcon trayIcon = null;
if (SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
java.awt.Image image = Toolkit.getDefaultToolkit().getImage("/home/realmon/dev/images/16852.png");
java.awt.event.ActionListener exitListener = new ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.exit(0);
}
};
java.awt.PopupMenu popup = new PopupMenu();
MenuItem exitItem = new MenuItem("Exit");
MenuItem captItem = new MenuItem("Capture");
exitItem.addActionListener(exitListener);
popup.add(captItem);
popup.add(exitItem);
trayIcon.addActionListener(defaultListener);
try {
tray.add(trayIcon);
} catch (AWTException e) {
System.err.println(e);
} |
|