public void run() {
        if (SystemTray.isSupported()) { //only launch if supported

            MouseListener mouseListener = new MouseListener() {

                @Override
                public void mouseClicked(MouseEvent e) { //show and hide the server window when left-click on the tray icon
                    if (vis == true) {
                        FriendsList.setVisible(false);
                        vis = false;
                    } else {
                        FriendsList.setVisible(true);
                        vis = true;
                    }
                }

                @Override
                public void mouseEntered(MouseEvent e) { //Not used
                }

                @Override
                public void mouseExited(MouseEvent e) {//Not used
                }

                @Override
                public void mousePressed(MouseEvent e) { //Not used
                }

                @Override
                public void mouseReleased(MouseEvent e) { //Not used
                }
            };

            SystemTray tray = SystemTray.getSystemTray();
            Image trayImage = Toolkit.getDefaultToolkit().getImage(imageURL);
            createMenu();
            trayIcon = new TrayIcon(trayImage, TOOLTIP, menu);
            trayIcon.setImageAutoSize(true);
            trayIcon.addMouseListener(mouseListener);
            try {
                tray.add(trayIcon);
            } catch (AWTException e) {
                System.err.println("Error starting tray: " + e);
            }
        }
    }