System.exit(0);
final JFrame frm = new JFrame("Dot Project Desktop Client");
PopupMenu popup = new PopupMenu();
MenuItem openItem = new MenuItem("Open");
MenuItem exitItem = new MenuItem("Exit");
popup.add(openItem);
popup.add(exitItem);
final TrayIcon trayIcon = new TrayIcon(IconHelper.getProductLogoImage(), "double click here to open Dot Project Client", popup);
final SystemTray tray = SystemTray.getSystemTray();
trayIcon.setImageAutoSize(true);
trayIcon.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frm.setVisible(true);
frm.setExtendedState(JFrame.MAXIMIZED_BOTH);
tray.remove(trayIcon);
}
});
ActionListener exitListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Exiting...");
tray.remove(trayIcon);
System.exit(0);
}
};
exitItem.addActionListener(exitListener);
ActionListener openListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
frm.setVisible(true);
frm.setExtendedState(JFrame.MAXIMIZED_BOTH);
tray.remove(trayIcon);