question: @ Override public void mouseDragged ( MouseEvent evt ) { int xTrans = 0 ; int yTrans = 0 ; if ( slider . getSnapToTicks ( ) ) { int pos = getLocationForValue ( getSnappedValue ( evt ) ) ; if ( pos > - 1 ) { if ( slider . getOrientation ( ) == JSlider . HORIZONTAL ) { xTrans = pos - evt . getX ( ) + offset ; evt . translatePoint ( xTrans , 0 ) ; } else { yTrans = pos - evt . getY ( ) + offset ; evt . translatePoint ( 0 , yTrans ) ; } } } delegate . mouseDragged ( evt ) ; evt . translatePoint ( xTrans , yTrans ) ; }
target:  Implements the actual 'snap while dragging' behaviour. If snap to ticks is enabled on this slider, then the location for the nearest tick/label is calculated and the click location is translated before being passed to the delegate.