Example usage for javax.swing JSlider getMinimum

List of usage examples for javax.swing JSlider getMinimum

Introduction

In this page you can find the example usage for javax.swing JSlider getMinimum.

Prototype

public int getMinimum() 

Source Link

Document

Returns the minimum value supported by the slider from the BoundedRangeModel.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JSlider slider = new JSlider();

    // Get the current value
    int value = slider.getValue();

    // Get the minimum value
    int min = slider.getMinimum();

    // Get the maximum value
    int max = slider.getMaximum();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JSlider slider = new JSlider();

    Dictionary table = slider.getLabelTable();

    ImageIcon icon = new ImageIcon("icon.gif");
    JLabel label = new JLabel(icon);

    // Set at desired positions
    table.put(new Integer(slider.getMinimum()), label);
    table.put(new Integer(slider.getMaximum()), label);

    // Force the slider to use the new labels
    slider.setLabelTable(table);/*  ww w  .jav  a2 s  . com*/

}

From source file:Main.java

public static void setTickMarkers(JSlider slider) {
    final int min = slider.getMinimum();
    final int max = slider.getMaximum();
    final int delta = max - min;

    if (delta > 0) {
        final int sliderSize;
        if (slider.getOrientation() == SwingConstants.HORIZONTAL)
            sliderSize = slider.getPreferredSize().width;
        else/* w ww .  j  ava  2s.c o m*/
            sliderSize = slider.getPreferredSize().height;

        // adjust ticks space on slider
        final int majTick = findBestMajTickSpace(sliderSize, delta);

        slider.setMinorTickSpacing(Math.max(1, majTick / 5));
        slider.setMajorTickSpacing(majTick);
        slider.setLabelTable(slider.createStandardLabels(slider.getMajorTickSpacing(), majTick));
    }
}

From source file:se.llbit.chunky.renderer.ui.Adjuster.java

@Override
public void stateChanged(ChangeEvent e) {
    JSlider source = (JSlider) e.getSource();
    double value;
    if (logarithmic) {
        value = (double) (source.getValue() - source.getMinimum())
                / (source.getMaximum() - source.getMinimum());
        double logMin = FastMath.log10(min);
        double logMax = FastMath.log10(max);
        double scale = logMax - logMin;
        value = FastMath.pow(10, value * scale + logMin);
    } else {//w w w  . j a  v  a  2 s .  c  o  m
        double scale = (max - min) / (source.getMaximum() - source.getMinimum());
        value = (source.getValue() - source.getMinimum()) * scale + min;
    }
    setTextField(value);
    valueChanged(value);
}