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 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); if (myOldValue != value) onThumbMove();