void (boolean animate) { int value = 0; int min = myScrollBar.getMinimum(); int max = myScrollBar.getMaximum(); int range = max - min; if (range <= 0) { myThumb.bounds.setBounds(0, 0, 0, 0); } else if (VERTICAL == myScrollBar.getOrientation()) { int extent = myScrollBar.getVisibleAmount(); int height = Math.max(convert(myTrack.bounds.height, extent, range), 2 * getThickness()); if (myTrack.bounds.height <= height) { myThumb.bounds.setBounds(0, 0, 0, 0); } else { value = getValue(); int maxY = myTrack.bounds.y + myTrack.bounds.height - height; int y = (value < max - extent) ? convert(myTrack.bounds.height - height, value - min, range - extent) : maxY; myThumb.bounds.setBounds(myTrack.bounds.x, adjust(y, myTrack.bounds.y, maxY), myTrack.bounds.width, height); animate |= myOldValue != value; // animate thumb on move } } else { int extent = myScrollBar.getVisibleAmount(); int width = Math.max(convert(myTrack.bounds.width, extent, range), 2 * getThickness()); if (myTrack.bounds.width <= width) { myThumb.bounds.setBounds(0, 0, 0, 0); } else { value = getValue(); int maxX = myTrack.bounds.x + myTrack.bounds.width - width; int x = (value < max - extent) ? convert(myTrack.bounds.width - width, value - min, range - extent) : maxX; if (!myScrollBar.getComponentOrientation().isLeftToRight()) x = myTrack.bounds.x - x + maxX; myThumb.bounds.setBounds(adjust(x, myTrack.bounds.x, maxX), myTrack.bounds.y, width, myTrack.bounds.height); animate |= myOldValue != value; // animate thumb on move } } myOldValue = value; if (animate) myAnimationBehavior.onThumbMove(); }