private void scroll() { ScrollBar scrollBar = (ScrollBar) TerraScrollBarSkin.this.getComponent(); int start = scrollBar.getStart(); int end = scrollBar.getEnd(); int extent = scrollBar.getExtent(); int value = scrollBar.getValue(); int adjustment; if (incrementType == Mouse.ScrollType.UNIT) { adjustment = direction * scrollBar.getUnitIncrement(); } else { adjustment = direction * scrollBar.getBlockIncrement(); } if (adjustment < 0) { int newValue = Math.max(value + adjustment, start); scrollBar.setValue(newValue); if (stopValue != -1 && newValue < stopValue) { // We've reached the explicit stop value stop(); } if (newValue == start) { // We implicit stop at the minimum scroll bar value stop(); } } else { int newValue = Math.min(value + adjustment, end - extent); scrollBar.setValue(newValue); if (stopValue != -1 && newValue > stopValue) { // We've reached the explicit stop value stop(); } if (newValue == end - extent) { // We implicitly stop at the maximum scroll bar value stop(); } } }