I'm trying to add a TrayIcon inside a Tray that already appears. I'm new in Java so i can be calling wrong methods. Could someone help me please? The code i use is:
if (!SystemTray.isSupported()) {
System.out.println("SystemTray is not supported");
return;
}
final SystemTray tray = SystemTray.getSystemTray();
Image image = Toolkit.getDefaultToolkit().getImage("systemtray.png");
PopupMenu popup = new PopupMenu();
final TrayIcon trayIcon = new TrayIcon(image, "The Tip Text", popup);
trayIcon.setImageAutoSize(true);
try {
tray.add(trayIcon);
} catch (AWTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ps.: image is in the same package of code.