new Thread(){ public void run(){ final AJSettings ajSettings = ApplejuiceFassade.getInstance().getAJSettings(); final JSlider uploadSlider = new JSlider(JSlider.VERTICAL, 0, 50, (int) ajSettings.getMaxUploadInKB()); final JSlider downloadSlider = new JSlider(JSlider.VERTICAL, 0, 300, (int) ajSettings.getMaxDownloadInKB()); uploadSlider.setPaintLabels(true); uploadSlider.setPaintTicks(true); uploadSlider.setPaintTrack(true); uploadSlider.setSnapToTicks(true); downloadSlider.setPaintLabels(true); downloadSlider.setPaintTicks(true); downloadSlider.setPaintTrack(true); downloadSlider.setSnapToTicks(true); final JMenu uploadMenu = new JMenu("Upload"); final JMenu downloadMenu = new JMenu("Download"); JPanel uploadPanel = new JPanel(new BorderLayout()); JPanel downloadPanel = new JPanel(new BorderLayout()); final JLabel label1 = new JLabel("50 kb/s"); final JLabel label2 = new JLabel("50 kb/s"); label1.setText(Long.toString(ajSettings.getMaxUploadInKB()) + " kb/s"); label2.setText(Long.toString(ajSettings.getMaxDownloadInKB()) + " kb/s"); uploadPanel.add(label1, BorderLayout.NORTH); uploadPanel.add(uploadSlider, BorderLayout.SOUTH); uploadMenu.add(uploadPanel); downloadPanel.add(label2, BorderLayout.NORTH); downloadPanel.add(downloadSlider, BorderLayout.SOUTH); downloadMenu.add(downloadPanel); uploadSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider slider = (JSlider) e.getSource(); label1.setText(Integer.toString(slider.getValue()) + " kb/s"); ajSettings.setMaxUpload(slider.getValue() * 1024); } }); downloadSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider slider = (JSlider) e.getSource(); label2.setText(Integer.toString(slider.getValue()) + " kb/s"); } }); uploadSlider.addMouseListener(new MouseAdapter(){ public void mouseReleased(MouseEvent e){ long down = downloadSlider.getValue() * 1024; long up = uploadSlider.getValue() * 1024; ApplejuiceFassade.getInstance().setMaxUpAndDown(up, down); } }); downloadSlider.addMouseListener(new MouseAdapter(){ public void mouseReleased(MouseEvent e){ long down = downloadSlider.getValue() * 1024; long up = uploadSlider.getValue() * 1024; ApplejuiceFassade.getInstance().setMaxUpAndDown(up, down); } }); SwingUtilities.invokeLater(new Runnable(){ public void run(){ popup.add(uploadMenu); popup.add(downloadMenu); } }); } }.start();
    public SwingTrayPopup makeSwingPopup() {        SwingTrayPopup popup = new SwingTrayPopup();        popupShowHideMenuItem = new JMenuItem("%Show");        popupShowHideMenuItem.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent ae) {                if (!isVisible()) {                    setVisible(true);                    toFront();                    requestFocus();                }                else {                    setVisible(false);                }            }        });        popup.add(popupShowHideMenuItem);        IconManager im = IconManager.getInstance();        versteckenIcon = im.getIcon("hide");        zeigenIcon = im.getIcon("applejuice");        Icon aboutIcon = im.getIcon("about");        popupAboutMenuItem = new JMenuItem("&Info", aboutIcon);        popupAboutMenuItem.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent ae) {                showAboutDialog();            }        });        popup.add(popupAboutMenuItem);        return popup;    }