Example usage for javax.swing JSlider getOrientation

List of usage examples for javax.swing JSlider getOrientation

Introduction

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

Prototype

public int getOrientation() 

Source Link

Document

Return this slider's vertical or horizontal orientation.

Usage

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/*www .j a  v a2  s  .  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));
    }
}