1248 if (scrollbar.getOrientation() == JScrollBar.VERTICAL ||
1249 scrollbar.getComponentOrientation().isLeftToRight()) {
1250 value = (int)(0.5 + ((thumbValue / thumbRange) * valueRange));
1251 } else {
1252 value = (int)(0.5 + (((thumbMax - thumbPos) / thumbRange) * valueRange));
1253 }
1254
1255 useCachedValue = true;
1256 scrollBarValue = value + model.getMinimum();
1257 scrollbar.setValue(adjustValueIfNecessary(scrollBarValue));
1258 }
1259 setThumbRollover(active);
1260 }
1261
1262 private int adjustValueIfNecessary(int value) {
1263 if (scrollbar.getParent() instanceof JScrollPane) {
1264 JScrollPane scrollpane = (JScrollPane)scrollbar.getParent();
1265 JViewport viewport = scrollpane.getViewport();
1266 Component view = viewport.getView();
1267 if (view instanceof JList) {
1268 JList list = (JList)view;
1269 if (DefaultLookup.getBoolean(list, list.getUI(),
1270 "List.lockToPositionOnScroll", false)) {
1271 int adjustedValue = value;
1272 int mode = list.getLayoutOrientation();
1273 int orientation = scrollbar.getOrientation();
1274 if (orientation == JScrollBar.VERTICAL && mode == JList.VERTICAL) {
1275 int index = list.locationToIndex(new Point(0, value));
1276 Rectangle rect = list.getCellBounds(index, index);
1277 if (rect != null) {
1278 adjustedValue = rect.y;
1279 }
1280 }
1281 if (orientation == JScrollBar.HORIZONTAL &&
1282 (mode == JList.VERTICAL_WRAP || mode == JList.HORIZONTAL_WRAP)) {
1283 if (scrollpane.getComponentOrientation().isLeftToRight()) {
1284 int index = list.locationToIndex(new Point(value, 0));
1285 Rectangle rect = list.getCellBounds(index, index);
1286 if (rect != null) {
1287 adjustedValue = rect.x;
1288 }
|
1248 if (scrollbar.getOrientation() == JScrollBar.VERTICAL ||
1249 scrollbar.getComponentOrientation().isLeftToRight()) {
1250 value = (int)(0.5 + ((thumbValue / thumbRange) * valueRange));
1251 } else {
1252 value = (int)(0.5 + (((thumbMax - thumbPos) / thumbRange) * valueRange));
1253 }
1254
1255 useCachedValue = true;
1256 scrollBarValue = value + model.getMinimum();
1257 scrollbar.setValue(adjustValueIfNecessary(scrollBarValue));
1258 }
1259 setThumbRollover(active);
1260 }
1261
1262 private int adjustValueIfNecessary(int value) {
1263 if (scrollbar.getParent() instanceof JScrollPane) {
1264 JScrollPane scrollpane = (JScrollPane)scrollbar.getParent();
1265 JViewport viewport = scrollpane.getViewport();
1266 Component view = viewport.getView();
1267 if (view instanceof JList) {
1268 JList<?> list = (JList)view;
1269 if (DefaultLookup.getBoolean(list, list.getUI(),
1270 "List.lockToPositionOnScroll", false)) {
1271 int adjustedValue = value;
1272 int mode = list.getLayoutOrientation();
1273 int orientation = scrollbar.getOrientation();
1274 if (orientation == JScrollBar.VERTICAL && mode == JList.VERTICAL) {
1275 int index = list.locationToIndex(new Point(0, value));
1276 Rectangle rect = list.getCellBounds(index, index);
1277 if (rect != null) {
1278 adjustedValue = rect.y;
1279 }
1280 }
1281 if (orientation == JScrollBar.HORIZONTAL &&
1282 (mode == JList.VERTICAL_WRAP || mode == JList.HORIZONTAL_WRAP)) {
1283 if (scrollpane.getComponentOrientation().isLeftToRight()) {
1284 int index = list.locationToIndex(new Point(value, 0));
1285 Rectangle rect = list.getCellBounds(index, index);
1286 if (rect != null) {
1287 adjustedValue = rect.x;
1288 }
|