I know below way to show a balloon message:
something.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
trayIcon.displayMessage("Tray", "Icon", TrayIcon.MessageType.INFO);
}
});
But is there any way to call trayIcon.displayMessage() from a method?
void showMsg(){
trayIcon.displayMessage("Tray", "Icon", TrayIcon.MessageType.INFO);
}
doesn't work and I have no idea what to do next.
This is how I created trayIcon:
if (SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
PopupMenu popup = new PopupMenu();
windowItem = new MenuItem("Show");
MenuItem openSettings = new MenuItem("Settings");
MenuItem areaShot = new MenuItem("sth");
MenuItem fullShot = new MenuItem("sth");
MenuItem aboutItem = new MenuItem("About");
MenuItem exitItem = new MenuItem("Exit");
popup.add(windowItem);
popup.add(openSettings);
popup.addSeparator();
popup.add(areaShot);
popup.add(fullShot);
popup.add(aboutItem);
popup.add(exitItem);
trayIcon = new TrayIcon(image, "App", popup);
trayIcon.setImageAutoSize(true);
}