Possible Duplicate:
How can I run a Windows GUI application on as a service?
I have added code for enable SystemTrayIcon for Windows 7. It is working fine with NetBeans application mode, while I am executing the application in windows services mode it is not working. Please find below code for your reference.
if (!java.awt.SystemTray.isSupported()) {
System.out.println("SystemTray is not supported");
return;
}
final PopupMenu popup = new PopupMenu();
Image img1 = new ImageIcon(DataReporter.class.getResource("/lookandfeel/data/xear_appIcon_16.png")).getImage();
ImageIcon icon = new ImageIcon(img1);
final TrayIcon trayIcon = new TrayIcon(icon.getImage());
trayIcon.setToolTip(DataReporterProps.softwareDescriptionText);
final java.awt.SystemTray tray = java.awt.SystemTray.getSystemTray();
MenuItem aboutItem = new MenuItem("About");
popup.add(aboutItem);
trayIcon.setPopupMenu(popup);
try {
tray.add(trayIcon);
} catch (AWTException e) {
System.out.println("Cannot add the TrayIcon!");
}
Please let me know if any code wants to be added for triggering in windows service mode.