slide = new JSlider( SwingConstants.HORIZONTAL, 0, 100, 79 ); slide.setMajorTickSpacing( 10); slide.setMinorTickSpacing( 5);
setPaintTicks
and setPaintLabels
The display of the tick marks and of their labels is turned on or off with the following methods:
setPaintTicks ( boolean state ) setPaintLabels( boolean state )
Sometimes you want the knob of a slider to stop only at the tick marks so that the value of the slider is an integer multiple of the minor tick spacing. Use this method:
setSnapToTicks( boolean state )
Ask that ticks and labels be displayed as in the picture and that the knob snap to the ticks.
slide = new JSlider( SwingConstants.HORIZONTAL, 0, 100, 79 ); slide.setMajorTickSpacing( 10 ); slide.setMinorTickSpacing( 5 ); slide.setPaintTicks ( _______); slide.setPaintLabels( _______); slide.setSnapToTicks( _______);