Java 类javax.swing.JSlider 实例源码

项目:VISNode    文件:InputEditor.java   
/**
 * Creates the image slider component
 * 
 * @return JComponent
 */
private JComponent buidSlider() {
    slider = new JSlider(0, 0);
    slider.setPreferredSize(new Dimension(120, 25));
    slider.setEnabled(false);
    slider.setOpaque(false);
    slider.setFocusable(false);
    slider.addChangeListener((ChangeEvent e) -> {
        if (input != null) {
            if (input instanceof MultiFileInput) {
                MultiFileInput multi = (MultiFileInput) input;
                input = new MultiFileInput(multi.getFiles(), slider.getValue());
                fireValueChanged();
            }
        }
    });
    return slider;
}
项目:incubator-netbeans    文件:BindingDesignSupportImpl.java   
@Override
public List<BindingDescriptor>[] getBindingDescriptors(RADComponent component) {
    BeanDescriptor beanDescriptor = component.getBeanInfo().getBeanDescriptor();
    List<BindingDescriptor>[] descs = getBindingDescriptors(null, beanDescriptor, false);
    Class<?> beanClass = component.getBeanClass();
    if (JTextComponent.class.isAssignableFrom(beanClass)) {
        // get rid of text_... descriptors
        descs[0] = filterDescriptors(descs[0], "text_"); // NOI18N
    } else if (JTable.class.isAssignableFrom(beanClass)
            || JList.class.isAssignableFrom(beanClass)
            || JComboBox.class.isAssignableFrom(beanClass)) {
        // get rid of selectedElement(s)_... descriptors
        descs[0] = filterDescriptors(descs[0], "selectedElement_"); // NOI18N
        descs[0] = filterDescriptors(descs[0], "selectedElements_"); // NOI18N
        // add elements descriptor
        BindingDescriptor desc = new BindingDescriptor("elements", List.class); // NOI18N
        descs[0].add(0, desc);
    } else if (JSlider.class.isAssignableFrom(beanClass)) {
        // get rid of value_... descriptor
        descs[0] = filterDescriptors(descs[0], "value_"); // NOI18N
    }
    return descs;
}
项目:rapidminer    文件:ExtendedJSliderToolTips.java   
public static void enableSliderToolTips(final JSlider slider) {
    slider.addChangeListener(new ChangeListener() {

        private boolean adjusting = false;
        private String oldTooltip;

        @Override
        public void stateChanged(ChangeEvent e) {
            if (slider.getModel().getValueIsAdjusting()) {
                if (!adjusting) {
                    oldTooltip = slider.getToolTipText();
                    adjusting = true;
                }
                slider.setToolTipText(String.valueOf(slider.getValue()));
                hideToolTip(slider);
                postToolTip(slider);
            } else {
                hideToolTip(slider);
                slider.setToolTipText(oldTooltip);
                adjusting = false;
                oldTooltip = null;
            }
        }
    });
}
项目:freecol    文件:RangeOptionUI.java   
/**
 * Creates a new {@code RangeOptionUI} for the given
 * {@code RangeOption}.
 *
 * @param option The {@code RangeOption} to make a user interface for
 * @param editable boolean whether user can modify the setting
 */
public RangeOptionUI(final RangeOption option, boolean editable) {
    super(option, editable);

    JSlider slider = getComponent();

    slider.setModel(new DefaultBoundedRangeModel(option.getValueRank(), 0,
            0, option.getItemValues().size()-1));

    Hashtable<Integer, JComponent> labels
        = new Hashtable<>();
    int index = 0;
    for (String string : option.getItemValues().values()) {
        if (option.localizeLabels()) {
            labels.put(index, Utility.localizedLabel(string));
        } else {
            labels.put(index, new JLabel(string));
        }
        index++;
    }

    slider.setLabelTable(labels);
    slider.setValue(option.getValueRank());
    slider.setMajorTickSpacing(1);
    slider.setSnapToTicks(true);
}
项目:sstore-soft    文件:ProcGui.java   
private void addSliderListener()
{
    m_slideProbability.addChangeListener(new ChangeListener()
    {

        @Override
        public void stateChanged(ChangeEvent e)
        {
            int value = ((JSlider) e.getSource()).getValue();

            String curProc = m_lstProcNames.getSelectedValue().toString();
            try
            {
                ProcEnv.setProbability(curProc, value);
                m_txtProbability.setText(Integer.toString(value));
            }
            catch (TotalProbabilityExceeds100Exception e1)
            {
                Integer nOldVal = ProcEnv.getProbability(curProc);
                m_slideProbability.setValue((nOldVal == null) ? 0 : nOldVal);
                m_notifier.showMsg(e1.getMessage(), false);
            }
        }
    });
}
项目:jaer    文件:PotPanel.java   
private void addBorderSetter(final JComponent s) {
        if (s instanceof JTextField || s instanceof JSlider || s instanceof JComboBox || s instanceof AbstractButton) {
            s.setFocusable(true);// sliders and combo boxes not normally focusable
            s.addFocusListener(this);
//            log.info("added border setter for "+s.getClass().getSimpleName());
        } else if (s instanceof Container) {
            Component[] components = s.getComponents();
            for (Component c : components) {
//                log.info("possibly adding border setter for "+c.getClass().getSimpleName());
                if (c instanceof JComponent) {
                    addBorderSetter((JComponent) c);
                }
            }
        }
    }
项目:VASSAL-src    文件:GenericListener.java   
protected boolean accept(Component jc) {
    if (extListener != null && extListener.accept(jc)) {
        return true;
    }
    if (!(jc instanceof JComponent)) {
        return false;
    }
    return isProbablyAContainer (jc) || 
            jc instanceof JList ||
            jc instanceof JComboBox ||
            jc instanceof JTree ||
            jc instanceof JToggleButton || //covers toggle, radio, checkbox
            jc instanceof JTextComponent ||
            jc instanceof JColorChooser ||
            jc instanceof JSpinner ||
            jc instanceof JSlider;
}
项目:VASSAL-src    文件:ZoneHighlight.java   
public Component getControls() {

      final JSlider slider = new JSlider(JSlider.HORIZONTAL,0,100,opacity);

      final HashMap<Integer,JLabel> labelTable = new HashMap<Integer,JLabel>();
      labelTable.put(0, new JLabel("Transparent"));
      labelTable.put(100, new JLabel("Opaque"));

      slider.setMajorTickSpacing(10);
      slider.setPaintTicks(true);
      // Note: JSlider uses the outdated Hashtable. Eventually Hashtable
      // will be deprecated and we'll be able to use the HashMap directly.
      slider.setLabelTable(new Hashtable<Integer,JLabel>(labelTable));
      slider.setPaintLabels(true);
      slider.setBorder(javax.swing.BorderFactory.createTitledBorder(name));
      slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
          final JSlider source = (JSlider) e.getSource();
          if (!source.getValueIsAdjusting()) {
            opacity = source.getValue();
          }
        }});

      return slider;
    }
项目:asgdrivestrength    文件:DrivestrengthMainWindow.java   
public DrivestrengthMainWindow() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }
    setLayout(new GridBagLayout());
    setTitle("ASGDrivestrength");
    setSize(500, 300);

    JSlider percentageEnergySlider = new JSlider(JSlider.HORIZONTAL,
            0, 100, 0);

    JButton runButton = new JButton("Run");
    add(percentageEnergySlider);
    add(runButton);

    setVisible(true);
}
项目:FreeCol    文件:RangeOptionUI.java   
/**
 * Creates a new {@code RangeOptionUI} for the given
 * {@code RangeOption}.
 *
 * @param option The {@code RangeOption} to make a user interface for
 * @param editable boolean whether user can modify the setting
 */
public RangeOptionUI(final RangeOption option, boolean editable) {
    super(option, editable);

    JSlider slider = getComponent();

    slider.setModel(new DefaultBoundedRangeModel(option.getValueRank(), 0,
            0, option.getItemValues().size()-1));

    Hashtable<Integer, JComponent> labels
        = new Hashtable<>();
    int index = 0;
    for (String string : option.getItemValues().values()) {
        if (option.localizeLabels()) {
            labels.put(index, Utility.localizedLabel(string));
        } else {
            labels.put(index, new JLabel(string));
        }
        index++;
    }

    slider.setLabelTable(labels);
    slider.setValue(option.getValueRank());
    slider.setMajorTickSpacing(1);
    slider.setSnapToTicks(true);
}
项目:ClashRoyale-Bot    文件:UI.java   
/**
 * @param prefix the text of the Label
 * @param sufix  thge text of the Label
 * @param minvalue start vlaue
 * @param maxvalue last value
 * @param startvalue inital value
 * @param komma 10^x offset for komma digits
 */
public Slider(String prefix, String sufix, int minvalue, int maxvalue, int startvalue, int komma, @Nullable ChangeListener cl,@Nullable Updater upd, boolean enabled) {//ChangeListener or Updater could be Null!
    slider = new JSlider(minvalue, maxvalue, startvalue);
    slider.addChangeListener(this);
    if(prefix != null)
        this.prefix = prefix;
    if(sufix != null) {
        this.sufix = sufix;
    }
    offset = komma;
    label = new JLabel(getLabelText());
    add(slider);
    add(label);
    listener = cl;
    updater = upd;
    slider.setEnabled(enabled);
    defaultvalue = startvalue;
}
项目:jaer    文件:SimpleVPotSliderTextControl.java   
/**
 * when slider is moved, event is sent here. The slider is the 'master' of the value in the text field.
 * Slider is linear scale, from pot min to pot max
 *
 * @param e
 *            the ChangeEvent
 */
private void sliderStateChanged(javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_sliderStateChanged
    if (sliderDontProcess) {
        return;
    }
    // we can get a double send here if user presses uparrow key, resulting in new pot value,
    // which updates the slider position, which ends up with a different bitvalue that makes a new
    // pot value.
    // See http://java.sun.com/docs/books/tutorial/uiswing/components/slider.html
    // System.out.println("slider state changed");
    // slider is only source of ChangeEvents
    JSlider s = (JSlider) evt.getSource();
    // System.out.println("slider state changed for "+pot);

    int v = s.getValue(); // slider value
    if (v == 0) {
        pot.setBitValue(0); // these pot chanages will come back to us as Observer events
        // a problem because they will updateAappearance, which will change slider state
        // and generate possibly a new slider changeevent
    }
    else {
        v = sliderValueFromBitValue(s);
        pot.setBitValue(v);
    }
}
项目:jdk8u-jdk    文件:Test6657026.java   
public static void main(String[] args) throws Exception {
    JSlider slider = new JSlider();
    test(slider);

    ThreadGroup group = new ThreadGroup("$$$");
    Thread thread = new Thread(group, new Test6657026());
    thread.start();
    thread.join();

    test(slider);
}
项目:incubator-netbeans    文件:JComponentBuilders.java   
protected void setupInstance(JSlider instance) {
    super.setupInstance(instance);

    instance.setPaintTicks(paintTicks);
    instance.setPaintTrack(paintTrack);
    instance.setPaintLabels(paintLabels);
    instance.setInverted(isInverted);
    if (sliderModel != null) instance.setModel(sliderModel.createInstance());
    instance.setMajorTickSpacing(majorTickSpacing);
    instance.setMinorTickSpacing(minorTickSpacing);
    instance.setSnapToTicks(snapToTicks);
}
项目:jaer    文件:ConfigurableIPotGUIControl.java   
/** Maps from bit value to linear/log slider value.
     * 
     * @param v bit value.
     * @param vmax max bit value.
     * @param slider the slider for the value.
     * @return the correct slider value.
     */
    private int bitVal2SliderVal(int v, int vmax, JSlider slider) {
        int s = 0;
        if (v < knee) {
            s = v;
        } else {
            double sm = slider.getMaximum();
            double vm = vmax;
            s = (int) (knee + Math.round((sm - knee) * log2((double) v - (knee - 1)) / log2(vm - (knee - 1))));
        }
//        log.info("bitValue=" + v + " -> sliderValue=" + s);
        return s;
    }
项目:openjdk-jdk10    文件:JSliderOperator.java   
/**
 * Maps {@code JSlider.setMinorTickSpacing(int)} through queue
 */
public void setMinorTickSpacing(final int i) {
    runMapping(new MapVoidAction("setMinorTickSpacing") {
        @Override
        public void map() {
            ((JSlider) getSource()).setMinorTickSpacing(i);
        }
    });
}
项目:rapidminer    文件:SliderUI.java   
@Override
protected void uninstallListeners(JSlider slider) {
    if (this.thumbPressedListener != null) {
        slider.removeMouseListener(this.thumbPressedListener);
        this.thumbPressedListener = null;
    }
    super.uninstallListeners(slider);
}
项目:openjdk-jdk10    文件:JSliderOperator.java   
/**
 * Maps {@code JSlider.getMajorTickSpacing()} through queue
 */
public int getMajorTickSpacing() {
    return (runMapping(new MapIntegerAction("getMajorTickSpacing") {
        @Override
        public int map() {
            return ((JSlider) getSource()).getMajorTickSpacing();
        }
    }));
}
项目:marathonv5    文件:RSliderTest.java   
public void sliderTest() {
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override public void run() {
            JSlider slider = (JSlider) ComponentUtils.findComponent(JSlider.class, frame);
            slider.setValue(25);
            RSlider rslider = new RSlider(slider, null, null, lr);
            rslider.focusLost(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("25", call.getState());
}
项目:GlitchKernel    文件:GlitchUIManager.java   
public void changeSliderValue(JComponent jComponent)
{
    if(jComponent instanceof JSlider && !((JSlider) jComponent).getValueIsAdjusting() && this.glitchArt.jAlgorithmList.getSelectedIndex() >= 0)
    {
        refreshSliderValues(true);
    }
    else if(jComponent instanceof JComboBox && this.glitchArt.jAlgorithmList.getSelectedIndex() >= 0)
    {
        refreshSliderValues(true);
    }
}
项目:EditCalculateAndChart    文件:grPlt.java   
@Override
    public void stateChanged(ChangeEvent e) {
                       JSlider source = (JSlider)e.getSource();
        if (!source.getValueIsAdjusting()) {
            int fps = source.getValue();
            String varName = source.getName();
            //regenerate data set and repaint
               int i;
            for( i = 1; i<vars.size();i++)
               if(vars.get(i).contentEquals(varName))
                   break;
           varsValues.set(i,rangesLeft.get(i).add(steps.get(i).multiply(new BigDecimal(fps))));
          //System.out.println(i); 
String   chartName=FunctionToPlot;


    for(int j = 1; j < vars.size();j++){
        chartName = SmartReplace.get(chartName,vars.get(j),varsValues.get(j).toPlainString()); 
         //chartName = chartName.replace(vars.get(j),varsValues.get(j).toPlainString()); 
        sliderLabels[j-1].setText(vars.get(j)+'='+varsValues.get(j).toPlainString());
      }
try{
       chartP.setChart(createChart(getDataset(),chartName));
}
catch(Exception ex){
 System.out.println(ex.getMessage());
}
    // chartPanel = new ChartPanel(chart);

//contentPanel.repaint();
//this.repaint();
//this.setVisible(true);
}
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
项目:openjdk-jdk10    文件:JSliderOperator.java   
/**
 * Maps {@code JSlider.getMinorTickSpacing()} through queue
 */
public int getMinorTickSpacing() {
    return (runMapping(new MapIntegerAction("getMinorTickSpacing") {
        @Override
        public int map() {
            return ((JSlider) getSource()).getMinorTickSpacing();
        }
    }));
}
项目:openjdk-jdk10    文件:JSliderDriver.java   
private Point getClickPoint(ComponentOperator oper, int direction, int orientation) {
    int x, y;
    boolean inverted = ((JSliderOperator) oper).getInverted();
    int realDirection = ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION;
    if (inverted) {
        if (direction == ScrollAdjuster.INCREASE_SCROLL_DIRECTION) {
            realDirection = ScrollAdjuster.DECREASE_SCROLL_DIRECTION;
        } else if (direction == ScrollAdjuster.DECREASE_SCROLL_DIRECTION) {
            realDirection = ScrollAdjuster.INCREASE_SCROLL_DIRECTION;
        } else {
            return null;
        }
    } else {
        realDirection = direction;
    }
    if (orientation == JSlider.HORIZONTAL) {
        if (realDirection == ScrollAdjuster.INCREASE_SCROLL_DIRECTION) {
            x = oper.getWidth() - 1;
        } else if (realDirection == ScrollAdjuster.DECREASE_SCROLL_DIRECTION) {
            x = 0;
        } else {
            return null;
        }
        y = oper.getHeight() / 2;
    } else if (orientation == JSlider.VERTICAL) {
        if (realDirection == ScrollAdjuster.INCREASE_SCROLL_DIRECTION) {
            y = 0;
        } else if (realDirection == ScrollAdjuster.DECREASE_SCROLL_DIRECTION) {
            y = oper.getHeight() - 1;
        } else {
            return null;
        }
        x = oper.getWidth() / 2;
    } else {
        return null;
    }
    return new Point(x, y);
}
项目:openjdk-jdk10    文件:TranslucentShapedFrameTest.java   
private void transparencySldStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_transparencySldStateChanged
    JSlider source = (JSlider)evt.getSource();
        int transl = transparencySld.getValue();
        if (testFrame != null) {
            testFrame.setOpacity((float)transl/100f);
        }
}
项目:openjdk-jdk10    文件:JSliderOperator.java   
/**
 * Maps {@code JSlider.getPaintLabels()} through queue
 */
public boolean getPaintLabels() {
    return (runMapping(new MapBooleanAction("getPaintLabels") {
        @Override
        public boolean map() {
            return ((JSlider) getSource()).getPaintLabels();
        }
    }));
}
项目:openjdk-jdk10    文件:JSliderOperator.java   
/**
 * Maps {@code JSlider.setValue(int)} through queue
 */
public void setValue(final int i) {
    runMapping(new MapVoidAction("setValue") {
        @Override
        public void map() {
            ((JSlider) getSource()).setValue(i);
        }
    });
}
项目:openjdk-jdk10    文件:CAccessible.java   
public void addNotificationListeners(Component c) {
    if (c instanceof Accessible) {
        AccessibleContext ac = ((Accessible)c).getAccessibleContext();
        ac.addPropertyChangeListener(new AXChangeNotifier());
    }
    if (c instanceof JProgressBar) {
        JProgressBar pb = (JProgressBar) c;
        pb.addChangeListener(new AXProgressChangeNotifier());
    } else if (c instanceof JSlider) {
        JSlider slider = (JSlider) c;
        slider.addChangeListener(new AXProgressChangeNotifier());
    }
}
项目:openjdk-jdk10    文件:JSliderOperator.java   
/**
 * Maps {@code JSlider.createStandardLabels(int, int)} through queue
 */
public Hashtable<?, ?> createStandardLabels(final int i, final int i1) {
    return ((Hashtable<?, ?>) runMapping(new MapAction<Object>("createStandardLabels") {
        @Override
        public Object map() {
            return ((JSlider) getSource()).createStandardLabels(i, i1);
        }
    }));
}
项目:openjdk-jdk10    文件:JSliderOperator.java   
/**
 * Maps {@code JSlider.setExtent(int)} through queue
 */
public void setExtent(final int i) {
    runMapping(new MapVoidAction("setExtent") {
        @Override
        public void map() {
            ((JSlider) getSource()).setExtent(i);
        }
    });
}
项目:jaer    文件:ConfigurableIPotGUIControl.java   
/** Maps from linear slider to linear/exponential bit value.
     *
     * @param vmax max bit value.
     * @param slider the slider.
     * @return the bit value.
     */
    private int sliderVal2BitVal(int vmax, JSlider slider) {
        int v = 0;
        int s = slider.getValue();
        if (s < knee) {
            v = s;
        } else {
            double sm = slider.getMaximum();
            double vm = vmax;
            v = (int) (knee - 1 + Math.round(Math.pow(2, (s - knee) * (log2(vm - (knee - 1))) / (sm - knee))));
        }
//        log.info("sliderValue=" + s + " -> bitValue=" + v);
        return v;
    }
项目:sumo    文件:MultiThumbSlider.java   
protected void uninstallListeners(JSlider slider) {
    slider.removeMouseListener(mThumbTrackListener);
    slider.removeMouseMotionListener(mThumbTrackListener);
    slider.removeFocusListener(focusListener);
    slider.removeComponentListener(componentListener);
    slider.removePropertyChangeListener(propertyChangeListener);
    slider.getModel().removeChangeListener(changeListener);
}
项目:openjdk-jdk10    文件:JSliderOperator.java   
/**
 * Maps {@code JSlider.setValueIsAdjusting(boolean)} through queue
 */
public void setValueIsAdjusting(final boolean b) {
    runMapping(new MapVoidAction("setValueIsAdjusting") {
        @Override
        public void map() {
            ((JSlider) getSource()).setValueIsAdjusting(b);
        }
    });
}
项目:OpenDA    文件:Query.java   
/** Get the current value in the entry with the given name
 *  and return as an integer.  If the entry is not a line,
 *  choice, or slider, then throw an exception.
 *  If it is a choice or radio button, then return the
 *  index of the first selected item.
 *  @return The value currently in the entry as an integer.
 *  @exception NoSuchElementException If there is no item with the
 *   specified name.  Note that this is a runtime exception, so it
 *   need not be declared explicitly.
 *  @exception NumberFormatException If the value of the entry cannot
 *   be converted to an integer.  This is a runtime exception, so it
 *   need not be declared explicitly.
 *  @exception IllegalArgumentException If the entry is not a
 *   choice, line, or slider.  This is a runtime exception, so it
 *   need not be declared explicitly.
 */
public int getIntValue(String name)
    throws
        IllegalArgumentException,
        NoSuchElementException,
        NumberFormatException {
    Object result = _entries.get(name);
    if (result == null) {
        throw new NoSuchElementException(
            "No item named \"" + name + " \" in the query box.");
    }
    if (result instanceof JTextField) {
        return (new Integer(((JTextField) result).getText())).intValue();
    } else if (result instanceof JSlider) {
        return ((JSlider) result).getValue();
    } else if (result instanceof JComboBox) {
        return ((JComboBox) result).getSelectedIndex();
    } else if (result instanceof JRadioButton[]) {
        // Regrettably, ButtonGroup gives no way to determine
        // which button is selected, so we have to search...
        JRadioButton[] buttons = (JRadioButton[]) result;
        for (int i = 0; i < buttons.length; i++) {
            if (buttons[i].isSelected()) {
                return i;
            }
        }
        // In theory, we shouldn't get here, but the compiler
        // is unhappy without a return.
        return -1;
    } else {
        throw new IllegalArgumentException(
            "Item named \""
                + name
                + "\" is not a text line or slider, and hence "
                + "cannot be converted to "
                + "an integer value.");
    }
}
项目:openjdk-jdk10    文件:MotifSliderUI.java   
protected Dimension getThumbSize() {
    if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
        return new Dimension( 30, 15 );
    }
    else {
        return new Dimension( 15, 30 );
    }
}
项目:openjdk-jdk10    文件:JSliderOperator.java   
/**
 * Maps {@code JSlider.setSnapToTicks(boolean)} through queue
 */
public void setSnapToTicks(final boolean b) {
    runMapping(new MapVoidAction("setSnapToTicks") {
        @Override
        public void map() {
            ((JSlider) getSource()).setSnapToTicks(b);
        }
    });
}
项目:openjdk-jdk10    文件:JSliderOperator.java   
/**
 * Maps {@code JSlider.setLabelTable(Dictionary)} through queue
 */
public void setLabelTable(final Dictionary<?, ?> dictionary) {
    runMapping(new MapVoidAction("setLabelTable") {
        @Override
        public void map() {
            ((JSlider) getSource()).setLabelTable(dictionary);
        }
    });
}
项目:jaer    文件:ShiftedSourceControlsCF.java   
/** Maps from bit value to linear/log slider value.
     * 
     * @param v bit value.
     * @param vmax max bit value.
     * @param slider the slider for the value.
     * @return the correct slider value.
     */
    private int bitVal2SliderVal(int v, int vmax, JSlider slider) {
        int s = 0;
        double sm = slider.getMaximum();
        double vm = vmax;
        s = (int) Math.round(sm*v/vm);;
//        log.info("bitValue=" + v + " -> sliderValue=" + s);
        return s;
    }
项目:TreeFlood    文件:LocalStorageExplorationGUIController.java   
@Override
public void stateChanged(final ChangeEvent e) {
    if (!(e.getSource() instanceof JSlider)) {
        return;
    }
    final JSlider sizeSlider = (JSlider) e.getSource();
    this.changeTreeProportions(sizeSlider.getValue());
}
项目:OpenJSharp    文件:MotifSliderUI.java   
protected Dimension getThumbSize() {
    if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
        return new Dimension( 30, 15 );
    }
    else {
        return new Dimension( 15, 30 );
    }
}
项目:MapAnalyst    文件:SliderUtils.java   
/**
 * Apply the font size to the labels of a slider. This must be called after
 * the labels of a slider are changed.
 *
 * First set up the label hash table and add it to the slider. Then, after
 * the slider has been added to a parent window and had its UI assigned,
 * call this method to change the label sizes.
 *
 * http://nadeausoftware.com/node/93#Settingsliderlabelfontsizes
 * 
 * @param slider
 */
public static void reapplyFontSize(JSlider slider) {

    Font font = slider.getFont();
    Dictionary dict = slider.getLabelTable();
    Enumeration keys = dict.keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Component label = (Component) dict.get(key);
        label.setFont(font);
        label.setSize(label.getPreferredSize());
    }

}