@Override protected void calculateThumbLocation(){
  super.calculateThumbLocation();
  if (slider.getSnapToTicks()) {
    int upperValue=slider.getValue() + slider.getExtent();
    int snappedValue=upperValue;
    int majorTickSpacing=slider.getMajorTickSpacing();
    int minorTickSpacing=slider.getMinorTickSpacing();
    int tickSpacing=0;
    if (minorTickSpacing > 0) {
      tickSpacing=minorTickSpacing;
    }
 else     if (majorTickSpacing > 0) {
      tickSpacing=majorTickSpacing;
    }
    if (tickSpacing != 0) {
      if ((upperValue - slider.getMinimum()) % tickSpacing != 0) {
        float temp=(float)(upperValue - slider.getMinimum()) / (float)tickSpacing;
        int whichTick=Math.round(temp);
        snappedValue=slider.getMinimum() + (whichTick * tickSpacing);
      }
      if (snappedValue != upperValue) {
        slider.setExtent(snappedValue - slider.getValue());
      }
    }
  }
  if (slider.getOrientation() == JSlider.HORIZONTAL) {
    int upperPosition=xPositionForValue(slider.getValue() + slider.getExtent());
    upperThumbRect.x=upperPosition - (upperThumbRect.width / 2);
    upperThumbRect.y=trackRect.y;
  }
 else {
    int upperPosition=yPositionForValue(slider.getValue() + slider.getExtent());
    upperThumbRect.x=trackRect.x;
    upperThumbRect.y=upperPosition - (upperThumbRect.height / 2);
  }
}

@ Override protected void calculateThumbLocation ( ) { super . calculateThumbLocation ( ) ; if ( slider . getSnapToTicks ( ) ) { int upperValue = slider . getValue ( ) + slider . getExtent ( ) ; int snappedValue = upperValue ; int majorTickSpacing = slider . getMajorTickSpacing ( ) ; int minorTickSpacing = slider . getMinorTickSpacing ( ) ; int tickSpacing = 0 ; if ( minorTickSpacing > 0 ) { tickSpacing = minorTickSpacing ; } else if ( majorTickSpacing > 0 ) { tickSpacing = majorTickSpacing ; } if ( tickSpacing != 0 ) { if ( ( upperValue - slider . getMinimum ( ) ) % tickSpacing != 0 ) { float temp = ( float ) ( upperValue - slider . getMinimum ( ) ) / ( float ) tickSpacing ; int whichTick = Math . round ( temp ) ; snappedValue = slider . getMinimum ( ) + ( whichTick * tickSpacing ) ; } if ( snappedValue != upperValue ) { slider . setExtent ( snappedValue - slider . getValue ( ) ) ; } } } if ( slider . getOrientation ( ) == JSlider . HORIZONTAL ) { int upperPosition = xPositionForValue ( slider . getValue ( ) + slider . getExtent ( ) ) ; upperThumbRect . x = upperPosition - ( upperThumbRect . width / 2 ) ; upperThumbRect . y = trackRect . y ; } else { int upperPosition = yPositionForValue ( slider . getValue ( ) + slider . getExtent ( ) ) ; upperThumbRect . x = trackRect . x ; upperThumbRect . y = upperPosition - ( upperThumbRect . height / 2 ) ; } }
updates the locations for both thumbs .
