List of utility methods to do JScrollBar
boolean | isPaintRequiredFor(javax.swing.JScrollBar jScrollBar) is Paint Required For if (jScrollBar != null) { return (jScrollBar.getMinimum() != jScrollBar.getValue()) || (jScrollBar.getMaximum() != jScrollBar.getVisibleAmount()); } else { return false; |
void | scrollByBlock(JScrollBar scrollbar, int direction) scroll By Block int oldValue = scrollbar.getValue(); int blockIncrement = scrollbar.getBlockIncrement(direction); int delta = blockIncrement * ((direction > 0) ? +1 : -1); int newValue = oldValue + delta; if (delta > 0 && newValue < oldValue) { newValue = scrollbar.getMaximum(); } else if (delta < 0 && newValue > oldValue) { newValue = scrollbar.getMinimum(); ... |
void | scrollByUnits(JScrollBar scrollbar, int direction, int units, boolean limitToBlock) scroll By Units int delta; int limit = -1; if (limitToBlock) { if (direction < 0) { limit = scrollbar.getValue() - scrollbar.getBlockIncrement(direction); } else { limit = scrollbar.getValue() + scrollbar.getBlockIncrement(direction); for (int i = 0; i < units; i++) { if (direction > 0) { delta = scrollbar.getUnitIncrement(direction); } else { delta = -scrollbar.getUnitIncrement(direction); int oldValue = scrollbar.getValue(); int newValue = oldValue + delta; if (delta > 0 && newValue < oldValue) { newValue = scrollbar.getMaximum(); } else if (delta < 0 && newValue > oldValue) { newValue = scrollbar.getMinimum(); if (oldValue == newValue) { break; if (limitToBlock && i > 0) { assert limit != -1; if ((direction < 0 && newValue < limit) || (direction > 0 && newValue > limit)) { break; scrollbar.setValue(newValue); |