@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;
}

@ 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 ; }
when the slider is clicked we need to record the offset from the thumb centre .
