List of usage examples for java.awt TrayIcon setPopupMenu
public void setPopupMenu(PopupMenu popup)
From source file:org.notebook.gui.MainFrame.java
private void installTrayIcon() { visibleTrayIcon = false;//from www. j a va2 s. c om try { if (java.awt.SystemTray.isSupported()) {// ???? java.awt.SystemTray st = java.awt.SystemTray.getSystemTray(); java.awt.TrayIcon ti = new java.awt.TrayIcon(appIcon16()); ti.setToolTip(this.getTitle()); ti.setPopupMenu(menu.getTrayMenu()); ti.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { events.fireEvent(MenuToolbar.SHOWWINDOW, mainFrame); } }); st.add(ti); visibleTrayIcon = true; } } catch (Exception e) { log.error(e, e); } }
From source file:org.shelloid.vpt.agent.App.java
private void setupSystemTray() { if (SystemTray.isSupported()) { try {/*w w w . jav a 2 s. co m*/ final ConfigForm configForm = new ConfigForm(false); final PopupMenu popup = new PopupMenu(); final TrayIcon trayIcon = new TrayIcon(createImage("/images/logo.jpg"), "Shelloid VPT Agent"); tray = SystemTray.getSystemTray(); MenuItem authenticateItem = new MenuItem("Configure Authentication"); MenuItem aboutItem = new MenuItem("About Shelloid VPT Agent"); MenuItem exitItem = new MenuItem("Exit"); trayIcon.setPopupMenu(popup); tray.add(trayIcon); authenticateItem.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { configForm.setVisible(true); } }); aboutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "Shelloid VPT Agent.\nVersion : " + getVersion() + "\n\n(c) 2014 Shelloid LLC. \nhttps://www.shelloid.com", "Shelloid VPT Client", JOptionPane.INFORMATION_MESSAGE); } }); exitItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(null, "Are you sure to exit Shelloid VPT Agent?", "Shelloid VPT Agent", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { shuttingDown = true; closeAllConnections(); System.exit(0); } } }); popup.add(authenticateItem); popup.add(aboutItem); popup.addSeparator(); popup.add(exitItem); } catch (Exception ex) { Platform.shelloidLogger.warn("System Tray Error: ", ex); } } else { System.out.println("System tray is not supported"); } }
From source file:zxmax.tools.timerreview.Main.java
private TrayIcon getTrayIcon() throws AWTException { final TrayIcon trayIcon = new TrayIcon( createImage("images/bulb.gif", I18N.getLabel(getClass(), "tray.icon.description"))); final SystemTray tray = SystemTray.getSystemTray(); tray.add(trayIcon);//from w w w.j ava 2s . c o m final PopupMenu popup = new PopupMenu(); trayIcon.setPopupMenu(popup); /* * Serve per aprire il popup sulla tray icon con il tasto sx del mouse. * Il problema chiuderla/nasconderla ... */ // trayIcon.addMouseListener(new TrayIconMouseAdapter(popup)); final MenuItem exitItem = new MenuItem(I18N.getLabel(getClass(), "exit")); final MenuItem newTimerItem = new MenuItem(I18N.getLabel(getClass(), "new.timer")); newTimerItem.setEnabled(false); final MenuItem infoItem = new MenuItem(I18N.getLabel(getClass(), "info")); popup.add(exitItem); popup.add(newTimerItem); popup.add(infoItem); exitItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tray.remove(trayIcon); System.exit(0); } }); newTimerItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { StartTimerWindow timer = new StartTimerWindow(); timer.setVisible(true); } }); infoItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { InfoWindow infoWindow = new InfoWindow(); infoWindow.setVisible(true); infoWindow.createBufferStrategy(1); } }); return trayIcon; }