List of usage examples for java.awt SystemTray isSupported
public static boolean isSupported()
From source file:org.gtdfree.GTDFree.java
private ActionMap getActionMap() { if (actionMap == null) { actionMap = new ActionMap(); AbstractAction a = new AbstractAction(Messages.getString("GTDFree.View.Closed")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override// w w w . ja v a2 s .c o m public void actionPerformed(ActionEvent e) { getEngine().getGlobalProperties().putProperty(GlobalProperties.SHOW_ALL_ACTIONS, !getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_ALL_ACTIONS)); } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.View.Closed.desc")); //$NON-NLS-1$ actionMap.put(GlobalProperties.SHOW_ALL_ACTIONS, a); a = new AbstractAction(Messages.getString("GTDFree.View.Empty")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { getEngine().getGlobalProperties().putProperty(GlobalProperties.SHOW_EMPTY_FOLDERS, !getEngine() .getGlobalProperties().getBoolean(GlobalProperties.SHOW_EMPTY_FOLDERS, true)); } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.View.Empty.desc")); //$NON-NLS-1$ actionMap.put(GlobalProperties.SHOW_EMPTY_FOLDERS, a); a = new AbstractAction(Messages.getString("GTDFree.View.ClosedLists")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { getEngine().getGlobalProperties().putProperty(GlobalProperties.SHOW_CLOSED_FOLDERS, !getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_CLOSED_FOLDERS)); } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.View.ClosedLists.desc")); //$NON-NLS-1$ actionMap.put(GlobalProperties.SHOW_CLOSED_FOLDERS, a); a = new AbstractAction(Messages.getString("GTDFree.View.Overview")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { getEngine().getGlobalProperties().putProperty(GlobalProperties.SHOW_OVERVIEW_TAB, !getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_OVERVIEW_TAB)); } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.View.Overview.desc")); //$NON-NLS-1$ actionMap.put(GlobalProperties.SHOW_OVERVIEW_TAB, a); a = new AbstractAction(Messages.getString("GTDFree.View.Quick")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { getEngine().getGlobalProperties().putProperty(GlobalProperties.SHOW_QUICK_COLLECT, !getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_QUICK_COLLECT)); } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.View.Quick.desc")); //$NON-NLS-1$ actionMap.put(GlobalProperties.SHOW_QUICK_COLLECT, a); a = new AbstractAction(Messages.getString("GTDFree.View.Tray")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { boolean b = !getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_TRAY_ICON); getEngine().getGlobalProperties().putProperty(GlobalProperties.SHOW_TRAY_ICON, b); if (b) { try { SystemTray.getSystemTray().add(getTrayIcon()); } catch (AWTException e1) { Logger.getLogger(this.getClass()).error("System tray icon initialization failed.", e1); //$NON-NLS-1$ } } else { SystemTray.getSystemTray().remove(getTrayIcon()); } } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.View.Tray.desc")); //$NON-NLS-1$ a.setEnabled(SystemTray.isSupported()); actionMap.put(GlobalProperties.SHOW_TRAY_ICON, a); a = new AbstractAction(Messages.getString("GTDFree.ImportExamples")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { getImportDialog().getDialog(getJFrame()).setVisible(true); } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.ImportExamples.desc")); //$NON-NLS-1$ actionMap.put("importDialog", a); //$NON-NLS-1$ } return actionMap; }
From source file:neembuu.uploader.NeembuuUploader.java
private void formWindowIconified(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowIconified if (!Application.get(Settings.class).minimizetotray() || !SystemTray.isSupported() || trayIcon == null || !isActive()) {//from www. ja va 2 s. com return; } NULogger.getLogger().info("Minimizing to Tray"); setVisible(false); try { SystemTray.getSystemTray().add(trayIcon); } catch (AWTException ex) { setVisible(true); Logger.getLogger(NeembuuUploader.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ui.main.MainViewController.java
private void showNotifications(String chat, String message) { // a general method for view notifications -> windows notification if (!isnotifiable.isSelected()) { return;//from w ww.jav a2s.c o m } URL url = System.class.getResource("/resources/LogoTransparent.png"); java.awt.Image image = Toolkit.getDefaultToolkit().getImage(url); TrayIcon trayIcon = new TrayIcon(image, "Instant Messenger Plus"); if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); trayIcon.setImageAutoSize(true); try { tray.add(trayIcon); } catch (AWTException e) { System.err.println("TrayIcon could not be added."); } trayIcon.displayMessage("IMP: " + chat, message, TrayIcon.MessageType.INFO); } }
From source file:org.yccheok.jstock.gui.MainFrame.java
private void createSystemTrayIcon() { if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); final Image image; if (Utils.isWindows7() || Utils.isWindows8()) { image = new javax.swing.ImageIcon(getClass().getResource("/images/128x128/chart.png")).getImage(); } else {// w w w . j a v a 2 s. c om image = new javax.swing.ImageIcon(getClass().getResource("/images/16x16/chart.png")).getImage(); } MouseListener mouseListener = new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { MainFrame.this.setVisible(true); MainFrame.this.setState(Frame.NORMAL); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }; ActionListener exitListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { MainFrame.this.setVisible(false); MainFrame.this.dispose(); } }; PopupMenu popup = new PopupMenu(); MenuItem defaultItem = new MenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Exit")); defaultItem.addActionListener(exitListener); popup.add(defaultItem); trayIcon = new TrayIcon(image, GUIBundle.getString("MainFrame_Application_Title"), popup); ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { } }; trayIcon.setImageAutoSize(true); trayIcon.addActionListener(actionListener); trayIcon.addMouseListener(mouseListener); try { tray.add(trayIcon); } catch (AWTException e) { trayIcon = null; JOptionPane.showMessageDialog(MainFrame.this, java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages") .getString("warning_message_trayicon_could_not_be_added"), java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages").getString( "warning_title_trayicon_could_not_be_added"), JOptionPane.WARNING_MESSAGE); } } else { // System Tray is not supported trayIcon = null; JOptionPane.showMessageDialog(MainFrame.this, java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages") .getString("warning_message_system_tray_is_not_supported"), java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages") .getString("warning_title_system_tray_is_not_supported"), JOptionPane.WARNING_MESSAGE); } }
From source file:org.yccheok.jstock.gui.JStock.java
private void createSystemTrayIcon() { if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); final Image image = new javax.swing.ImageIcon(getClass().getResource("/images/128x128/chart.png")) .getImage();/* w w w . ja v a 2s .c om*/ MouseListener mouseListener = new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { JStock.this.setVisible(true); JStock.this.setState(Frame.NORMAL); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }; ActionListener exitListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JStock.this.setVisible(false); JStock.this.dispose(); } }; PopupMenu popup = new PopupMenu(); MenuItem defaultItem = new MenuItem( java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Exit")); defaultItem.addActionListener(exitListener); popup.add(defaultItem); trayIcon = new TrayIcon(image, GUIBundle.getString("MainFrame_Application_Title"), popup); ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { } }; trayIcon.setImageAutoSize(true); trayIcon.addActionListener(actionListener); trayIcon.addMouseListener(mouseListener); try { tray.add(trayIcon); } catch (AWTException e) { trayIcon = null; JOptionPane.showMessageDialog(JStock.this, java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages") .getString("warning_message_trayicon_could_not_be_added"), java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages").getString( "warning_title_trayicon_could_not_be_added"), JOptionPane.WARNING_MESSAGE); } } else { // System Tray is not supported trayIcon = null; JOptionPane.showMessageDialog(JStock.this, java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages") .getString("warning_message_system_tray_is_not_supported"), java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages") .getString("warning_title_system_tray_is_not_supported"), JOptionPane.WARNING_MESSAGE); } }