private void setSysTray()
    {
        if (SystemTray.isSupported())
        {
            popupMenu = new PopupMenu();
            itemExit = new MenuItem("Exit");
            itemExit.addActionListener(new ActionListener()
            {

                @Override
                public void actionPerformed(ActionEvent arg0)
                {
                    System.exit(0);
                }
            });

            itemShow = new MenuItem("Show Timer");
            itemShow.addActionListener(new ActionListener()
            {

                @Override
                public void actionPerformed(ActionEvent arg0)
                {
                    setVisible(true);
                    setState(JFrame.NORMAL);
                }
            });

            popupMenu.add(itemShow);
            popupMenu.add(itemExit);

            systemTray = SystemTray.getSystemTray();
            trayIconImage = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/icon-16.png"));
            trayIcon = new TrayIcon(trayIconImage, "Timer", popupMenu);
            trayIcon.addActionListener(new ActionListener()
            {
                @Override
                public void actionPerformed(ActionEvent e)
                {
                    setVisible(true);
                    setState(JFrame.NORMAL);
                }
            });

        }
        addWindowStateListener(new WindowStateListener()
        {
            @Override
            public void windowStateChanged(WindowEvent e)
            {

                if (e.getNewState() == JFrame.ICONIFIED)
                {
                    try
                    {
                        setVisible(false);
                        systemTray.add(trayIcon);
                    } catch (AWTException e1)
                    {
                        System.out.println(e1);
                    }
                }
                if (e.getNewState() == JFrame.NORMAL)
                {
                    setVisible(true);
                    systemTray.remove(trayIcon);
                }

            }
        });
    }