public void makeTray() {
MenuItem exititem = new MenuItem("exit");
PopupMenu menu = new PopupMenu("My Menu");
menu.add(exititem);
exititem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(1);
}
});
TrayIcon myTray =
new TrayIcon(Toolkit.getDefaultToolkit().getImage(trayURL), "chat", menu);
SystemTray tray = SystemTray.getSystemTray();
try {
tray.add(myTray);
} catch (AWTException e1) {
System.out.println(e1.getMessage());
}
myTray.setImageAutoSize(true);
}