Examples of SystemTray


Examples of java.awt.SystemTray

  {
    // Do nothing if there is no system tray support
    if (!SystemTray.isSupported()) return;
   
    // Initialize the system tray with the icon
    SystemTray tray = SystemTray.getSystemTray();
    Image image = Toolkit.getDefaultToolkit().getImage("icon.gif");
   
    // Create the popup menu
    PopupMenu popup = new PopupMenu();
    MenuItem restoreItem = new MenuItem("Restore");
    MenuItem exitItem = new MenuItem("Exit");
   
    // Treat the "Exit" option as closing the window
    ActionListener exitListener = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        app.new WindowExitAdapter().windowClosing(null);
        System.exit(0);
      }
    };
   
    // Treat the "Restore" option as a deiconification
    ActionListener restoreListener = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        app.new WindowRestoreAdapter().windowDeiconified(null);
      }
    };
   
    restoreItem.addActionListener(restoreListener);
    exitItem.addActionListener(exitListener);
   
    popup.add(restoreItem);
    popup.add(exitItem);
   
    trayIcon = new TrayIcon(image, "StreamTracker", popup);
   
    trayIcon.setImageAutoSize(true);
   
    trayIcon.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent arg0) {
        app.new WindowRestoreAdapter().windowDeiconified(null);
      }
    });
   
    try {
      tray.add(trayIcon);
    } catch (AWTException e) {
      System.out.println("Could not be added");
    }
  }
View Full Code Here

Examples of java.awt.SystemTray

                mainWindow.setMinimumSize(new Dimension(640, 480));
                mainWindow.pack();               
               
                // Icona a la safata del sistema
                if(SystemTray.isSupported()){
                    SystemTray tray = SystemTray.getSystemTray();
                   
                    String icon = productDefinition.getIcon();
                    Image image = Toolkit.getDefaultToolkit().getImage(getClass().getResource(icon));
                    trayIcon = new TrayIcon(image, fullVersionName);
                    // Es redimensiona la imatge per tal que s'adapti a l'espai disponible
                    trayIcon.setImageAutoSize(true);
                    try{
                        tray.add(trayIcon);
                    }
                    catch(AWTException e){
                        log.error("Error en afegir la icona de l'aplicació a la safata del sistema");
                    }
                }
View Full Code Here

Examples of java.awt.SystemTray

        jXTrayIcon.setJPopupMenu(popup);
        jXTrayIcon.setDoubleClickListener(showOptionsWindow);
       
   
    SystemTray tray = SystemTray.getSystemTray();
    try {
        tray.add(jXTrayIcon);
        backgroundWorkers.setTrayIconToHandle(jXTrayIcon);
        if (backgroundWorkers.isFirstStart()){
          jXTrayIcon.displayMessage(null, "��������� \"��������\" ��������", TrayIcon.MessageType.INFO);
        }
    } catch (AWTException e) {
View Full Code Here

Examples of java.awt.SystemTray

            @Override
            public void mouseClicked(MouseEvent e) {
//        System.exit(0);
                if (SystemTray.isSupported()) {
                    final SystemTray tray = SystemTray.getSystemTray();

                    Image image = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/icons/" + icons.getString("icon_tray")));
                    PopupMenu popup = new PopupMenu();
                    trayIcon = new TrayIcon(image, "jTimer - " + TimerPanel.getInstance().getT(), popup);

                    trayIcon.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            Timer.getInstance().setVisible(true);
                            tray.remove(trayIcon);
                        }
                    });

                    MenuItem item = new MenuItem("Close jTimer");
                    item.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            tray.remove(trayIcon);
                            System.exit(0);
                        }

                    });
                    SwingUtilities.getRoot((JComponent) e.getSource()).setVisible(false);
                    popup.add(item);
                    try {
                        tray.add(trayIcon);
                    } catch (AWTException e1) {
                        System.err.println("Can't add to tray");
                    }
                } else {
                    System.err.println("Tray unavailable");
View Full Code Here

Examples of java.awt.SystemTray

  }

  private void makeTrayIcon() {
    if (SystemTray.isSupported()) {

      SystemTray tray = SystemTray.getSystemTray();

      Image image;
      try {
        image = ImageIO.read(new File(
            "assets\\themes\\default\\tray.png"));
      } catch (IOException e1) {
        image = new BufferedImage(1, 1, BufferedImage.OPAQUE);
      }

      PopupMenu popup = new PopupMenu();
      makeTrayManu(popup);

      trayIcon = new TrayIcon(image, "Settler Server", popup);
      trayIcon.setImageAutoSize(true);

      try {
        tray.add(trayIcon);
      } catch (AWTException e) {
        System.err.println("TrayIcon could not be added.");
      }

    } else {
View Full Code Here

Examples of java.awt.SystemTray

      addToSystemTray();
      return new TrayIconStatus(trayIcon, images);
   }

   private void addToSystemTray() throws AWTException {
      SystemTray systemTray = SystemTray.getSystemTray();
      systemTray.add(trayIcon);
   }
View Full Code Here

Examples of java.awt.SystemTray

        final TrayIcon trayIcon;       
        this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

        if (SystemTray.isSupported())
        {
            SystemTray tray = SystemTray.getSystemTray();
            Image image = Toolkit.getDefaultToolkit().getImage("./images/sms-icon.jpg");

            MouseListener mouseListener = new MouseListener()
            {
                public void mouseClicked(MouseEvent e)
                {
                    //System.out.println("Tray Icon - Mouse clicked!");
                   
                }

                public void mouseEntered(MouseEvent e)
                {
                    //System.out.println("Tray Icon - Mouse entered!");
                }

                public void mouseExited(MouseEvent e)
                {
                    //System.out.println("Tray Icon - Mouse exited!");
                }

                public void mousePressed(MouseEvent e)
                {
                    //System.out.println("Tray Icon - Mouse pressed!");
                }

                public void mouseReleased(MouseEvent e)
                {
                    //System.out.println("Tray Icon - Mouse released!");
                }
        };

        ActionListener exitListener = new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                //System.out.println("Exiting...");
                int reply=javax.swing.JOptionPane.showConfirmDialog(rootPane, "Are you sure you want exit?","SMS Manager",1);
                if(reply==0)
                    System.exit(0);
            }
        };

        PopupMenu popup = new PopupMenu();
        MenuItem defaultItem = new MenuItem("Exit");
        defaultItem.addActionListener(exitListener);
        popup.add(defaultItem);

        trayIcon = new TrayIcon(image, "SMS Manager", popup);

        ActionListener actionListener = new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {             
                   // double click
                setVisible(true);
            }
        };

        trayIcon.setImageAutoSize(true);
        trayIcon.addActionListener(actionListener);
        trayIcon.addMouseListener(mouseListener);

        try
        {
            tray.add(trayIcon);
        }
        catch (AWTException e)
        {
            System.err.println("TrayIcon could not be added.");
        }
View Full Code Here

Examples of net.java.sip.communicator.impl.osdependent.SystemTray

    /**
     * Initializes a new <tt>SystrayServiceJdicImpl</tt> instance.
     */
    public SystrayServiceJdicImpl()
    {
        SystemTray systray;

        try
        {
            systray = SystemTray.getDefaultSystemTray();
        }
View Full Code Here

Examples of net.java.sip.communicator.impl.osdependent.SystemTray

    /**
     * Initializes a new <tt>SystrayServiceJdicImpl</tt> instance.
     */
    public SystrayServiceJdicImpl()
    {
        SystemTray systray;

        try
        {
            systray = SystemTray.getDefaultSystemTray();
        }
View Full Code Here

Examples of org.jdesktop.jdic.tray.SystemTray

    private final TrayIcon _trayIcon;
    private Server _server = null;

    public SysTray() {
        SystemTray tray = SystemTray.getDefaultSystemTray();
        TrayIcon icon = new TrayIcon(_icons[NORMAL_DUKE], TITLE, createMenu());
        icon.setIconAutoSize(true);
        tray.addTrayIcon(icon);
        this._trayIcon = icon;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.