50, (int) ajSettings.getMaxUploadInKB());
(int)maxUpload, (int) ajSettings.getMaxUploadInKB()); long maxDownload = 300; if (ajSettings.getMaxDownloadInKB() > maxDownload){ maxDownload = ajSettings.getMaxDownloadInKB() + 20; }
            public void run() {                final AJSettings ajSettings = ApplejuiceFassade.getInstance().                    getAJSettings();                if ( ajSettings != null){                    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");                        }                    });                    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) {                            if (uploadSlider.getValue() <                                uploadSlider.getMaximum()                                && uploadSlider.getValue() > 0) {                                long down = downloadSlider.getValue() * 1024;                                long up = uploadSlider.getValue() * 1024;                                ApplejuiceFassade.getInstance().setMaxUpAndDown(                                    up,                                    down);                            }                            else {                                uploadSlider.setValue( (int) ajSettings.                                    getMaxUploadInKB());                            }                        }                    });                    downloadSlider.addMouseListener(new MouseAdapter() {                        public void mouseReleased(MouseEvent e) {                            if (downloadSlider.getValue() <                                downloadSlider.getMaximum()                                && downloadSlider.getValue() > 0) {                                long down = downloadSlider.getValue() * 1024;                                long up = uploadSlider.getValue() * 1024;                                ApplejuiceFassade.getInstance().setMaxUpAndDown(                                    up,                                    down);                            }                            else {                                downloadSlider.setValue( (int) ajSettings.                                    getMaxDownloadInKB());                            }                        }                    });                    SwingUtilities.invokeLater(new Runnable() {                        public void run() {                            popup.add(uploadMenu);                            popup.add(downloadMenu);                        }                    });                }            }