JSlider class) lets the user easily select from a range of integer
values. Use sliders for integer input whenever you can. They
are easier for the user than text fields, and there is no possibility of
illegal input values, so your programming is simpler.
JSlider s = new JSlider(orientation, min, max, initial);
orientation: JSlider.HORIZONTAL or JSlider.VERTICALmin: The minimum value.max: The maximum value.initial: The initial value.JSlider sl = new JSlider(JSlider.HORIZONTAL, 0, 20, 10);
setPaintTicks(true)
to make the tick marks appear.
Here is an example that sets major tick marks every 10 values and minor
tick marks every 1 value:
sl.setMajorTickSpacing(10); // sets numbers for biggest tick marks sl.setMinorTickSpacing(1); // smaller tick marks sl.setPaintTicks(true); // display the ticks
sl.setPaintLabels(true);
setLabelTable(...).
You can also specify which end of the slider should have the high or low values
using setInverted(true/false).