Java Swing How to - Move the slider by a fixed amount by setting the extent








Question

We would like to know how to move the slider by a fixed amount by setting the extent.

Answer

/* w  w w  . j ava 2  s. c  o m*/
import javax.swing.JSlider;

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

    // Set an extent
    int extent = 10;
    slider.setExtent(extent);
  }
}