question: @ Override public void mousePressed ( MouseEvent evt ) { int pos = ( slider . getOrientation ( ) == JSlider . HORIZONTAL ) ? evt . getX ( ) : evt . getY ( ) ; int loc = getLocationForValue ( getSnappedValue ( evt ) ) ; this . offset = ( loc < 0 ) ? 0 : pos - loc ; }
target:  When the slider is clicked we need to record the offset from the thumb centre.