int height = Math.max(convert(myTrackBounds.height, extent, range), 2 * getThickness()); if (myTrackBounds.height <= height) { myThumbBounds.setBounds(0, 0, 0, 0); value = getValue(); int maxY = myTrackBounds.y + myTrackBounds.height - height; int y = (value < max - extent) ? convert(myTrackBounds.height - height, value - min, range - extent) : maxY; myThumbBounds.setBounds(myTrackBounds.x, adjust(y, myTrackBounds.y, maxY), myTrackBounds.width, height); if (myOldValue != value) onThumbMove(); int width = Math.max(convert(myTrackBounds.width, extent, range), 2 * getThickness()); if (myTrackBounds.width <= width) { myThumbBounds.setBounds(0, 0, 0, 0); value = getValue(); int maxX = myTrackBounds.x + myTrackBounds.width - width; int x = (value < max - extent) ? convert(myTrackBounds.width - width, value - min, range - extent) : maxX; if (!myScrollBar.getComponentOrientation().isLeftToRight()) x = myTrackBounds.x - x + maxX; myThumbBounds.setBounds(adjust(x, myTrackBounds.x, maxX), myTrackBounds.y, width, myTrackBounds.height);