private void setValueFrom(MouseEvent event) {
      int x = event.getX();
      int y = event.getY();

      int thumbMin, thumbMax, thumbPos;
      if (Adjustable.VERTICAL == myScrollBar.getOrientation()) {
        thumbMin = myTrack.bounds.y;
        thumbMax = myTrack.bounds.y + myTrack.bounds.height - myThumb.bounds.height;
        thumbPos = MathUtil.clamp(y - myOffset, thumbMin, thumbMax);
        if (myThumb.bounds.y != thumbPos) {
          int minY = Math.min(myThumb.bounds.y, thumbPos);
          int maxY = Math.max(myThumb.bounds.y, thumbPos) + myThumb.bounds.height;
          myThumb.bounds.y = thumbPos;
          if (myAnimationBehavior != null) {
            myAnimationBehavior.onThumbMove();
          }
          repaint(myThumb.bounds.x, minY, myThumb.bounds.width, maxY - minY);
        }
      }
      else {
        thumbMin = myTrack.bounds.x;
        thumbMax = myTrack.bounds.x + myTrack.bounds.width - myThumb.bounds.width;
        thumbPos = MathUtil.clamp(x - myOffset, thumbMin, thumbMax);
        if (myThumb.bounds.x != thumbPos) {
          int minX = Math.min(myThumb.bounds.x, thumbPos);
          int maxX = Math.max(myThumb.bounds.x, thumbPos) + myThumb.bounds.width;
          myThumb.bounds.x = thumbPos;
          if (myAnimationBehavior != null) {
            myAnimationBehavior.onThumbMove();
          }
          repaint(minX, myThumb.bounds.y, maxX - minX, myThumb.bounds.height);
        }
      }
      int valueMin = myScrollBar.getMinimum();
      int valueMax = myScrollBar.getMaximum() - myScrollBar.getVisibleAmount();
      // If the thumb has reached the end of the scrollbar, then set the value to its maximum.
      // Otherwise, compute the value as accurately as possible.
      boolean isDefaultOrientation = Adjustable.VERTICAL == myScrollBar.getOrientation() || myScrollBar.getComponentOrientation().isLeftToRight();
      if (thumbPos == thumbMax) {
        myScrollBar.setValue(isDefaultOrientation ? valueMax : valueMin);
      }
      else {
        int valueRange = valueMax - valueMin;
        int thumbRange = thumbMax - thumbMin;
        int thumbValue = isDefaultOrientation
                         ? thumbPos - thumbMin
                         : thumbMax - thumbPos;
        isValueCached = true;
        myCachedValue = valueMin + convert(valueRange, thumbValue, thumbRange);
        myScrollBar.setValue(myCachedValue);
      }
      if (!isDragging) updateMouse(x, y);
    }
private void setValueFrom(MouseEvent event)