Java Swing How to - Change the minimum/maximum value








Question

We would like to know how to change the minimum/maximum value.

Answer

//from  w w w .  j  a  v  a  2 s .c  o  m

import javax.swing.JSlider;

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

    int newMin = 0;
    slider.setMinimum(newMin);

    int newMax = 256;
    slider.setMaximum(newMax);
  }
}