JScrollBar scrollBar = getScrollBar(); int amount = (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) ? event.getUnitsToScroll() * scrollBar.getUnitIncrement() : (event.getWheelRotation() < 0 ? -1 : 1) * scrollBar.getBlockIncrement();
delta = toScroll.getUnitIncrement(direction); } else { delta = -toScroll.getUnitIncrement(direction);
@Override public void actionPerformed (ActionEvent e) { final JScrollBar vertical = component.getVerticalScrollBar(); vertical.setValue(vertical.getValue() - vertical.getUnitIncrement()); }
@Override public void actionPerformed (ActionEvent e) { final JScrollBar vertical = component.getVerticalScrollBar(); vertical.setValue(vertical.getValue() + vertical.getUnitIncrement()); }
private void scrollUp() { final int unitIncrement = scrollBar.getUnitIncrement(); final int value = scrollBar.getValue(); int newValue = value - unitIncrement; if (newValue <= 0) { newValue = 0; } scrollBar.setValue(newValue); }
@RunsInCurrentThread @Nonnull private static Pair<Point, Integer> scrollUnitInfo(@Nonnull JScrollBar scrollBar, @Nonnull JScrollBarLocation location, int times) { Point where = blockLocation(scrollBar, location, times); int count = times * scrollBar.getUnitIncrement(); return Pair.of(where, scrollBar.getValue() + count); }
@Override public void actionPerformed (ActionEvent e) { final JScrollBar horizontal = component.getHorizontalScrollBar(); horizontal.setValue(horizontal.getValue() - horizontal.getUnitIncrement()); }
@Override public void actionPerformed (ActionEvent e) { final JScrollBar horizontal = component.getHorizontalScrollBar(); horizontal.setValue(horizontal.getValue() + horizontal.getUnitIncrement()); }
/** Invoked when the component's size changes. Reset scrollable increment, because * page-down/up is relative to current view size. */ public void componentResized(ComponentEvent e) { JScrollBar bar = getVerticalScrollBar(); // NOTE: use the scroll pane size--the XHTMLPanel size is a virtual size of the entire // page // want to page down leaving the current line at the bottom be the first at the top // TODO: this will only work once unit increment is set correctly; multiplier is a workaround (PWW 28-01-05) int incr = (int)(getSize().getHeight() - (bar.getUnitIncrement(1) * 3)); getVerticalScrollBar().setBlockIncrement(incr); } });
private void scrollDown() { final int unitIncrement = scrollBar.getUnitIncrement(); final int value = scrollBar.getValue(); final int maxValue = scrollBar.getMaximum() - scrollBar.getVisibleAmount(); int newValue = value + unitIncrement; if (newValue >= maxValue) { newValue = maxValue; } scrollBar.setValue(newValue); }
private static void scroll(JScrollBar scroller, MouseWheelEvent event) { if (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int direction = event.getUnitsToScroll() < 0 ? -1 : 1; int increment = scroller.getUnitIncrement(direction); int oldValue = scroller.getValue(); int newValue = oldValue + increment * direction; if (oldValue != newValue) scroller.setValue(newValue); event.consume(); } }
public void actionPerformed(ActionEvent evt) { JScrollBar sb = getVerticalScrollBar(); sb.getModel().setValue(sb.getModel().getValue() - sb.getUnitIncrement(-1)); } });
public void actionPerformed(ActionEvent evt) { JScrollBar sb = getVerticalScrollBar(); sb.getModel().setValue(sb.getModel().getValue() + sb.getUnitIncrement(1)); } });
public void actionPerformed(ActionEvent evt) { JScrollBar sb = getVerticalScrollBar(); sb.getModel().setValue(sb.getModel().getValue() + sb.getUnitIncrement(1)); } });
public void actionPerformed(ActionEvent evt) { JScrollBar sb = getVerticalScrollBar(); sb.getModel().setValue(sb.getModel().getValue() - sb.getUnitIncrement(-1)); } });
public void actionPerformed(ActionEvent evt) { JScrollBar sb = getVerticalScrollBar(); sb.getModel().setValue(sb.getModel().getValue() - sb.getUnitIncrement(-1)); } });
public void actionPerformed(ActionEvent evt) { JScrollBar sb = getVerticalScrollBar(); sb.getModel().setValue(sb.getModel().getValue() + sb.getUnitIncrement(1)); } });
@Override public void mouseWheelMoved(MouseWheelEvent event) { JScrollBar scrollBar = getScrollBar(); int amount = (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) ? event.getUnitsToScroll() * scrollBar.getUnitIncrement() : (event.getWheelRotation() < 0 ? -1 : 1) * scrollBar.getBlockIncrement(); scrollBar.setValue(scrollBar.getValue() + amount); event.consume(); } });
public void mouseWheelMoved(MouseWheelEvent e) { final JScrollBar sb = (vertical.isVisible()) ? vertical : horizontal; // vertical is preferred if(e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { final int amt = e.getUnitsToScroll() * sb.getUnitIncrement(); sb.setValue(sb.getValue() + amt); } else if(e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL){ final int amt = e.getWheelRotation() * sb.getBlockIncrement(); sb.setValue(sb.getValue() + amt); } }// mouseWheelMoved() }// inner class WheelListener
public void adjustmentValueChanged(AdjustmentEvent e) { JScrollBar rSB = rightScrollPane.getVerticalScrollBar(); verticalScrollBar.removeAdjustmentListener(verticalScrollBarAdjustementListener); verticalScrollBar.setMinimum(rSB.getMinimum()); verticalScrollBar.setMaximum(rSB.getMaximum()); verticalScrollBar.setBlockIncrement(rSB.getBlockIncrement()); verticalScrollBar.setUnitIncrement(rSB.getUnitIncrement()); verticalScrollBar.setVisibleAmount(rSB.getVisibleAmount()); verticalScrollBar.addAdjustmentListener(verticalScrollBarAdjustementListener); } }