private void imageDown() { final JScrollBar bar = scrollPane.getVerticalScrollBar(); bar.setValue(bar.getValue() + bar.getBlockIncrement()); }
private void imageUp() { final JScrollBar bar = scrollPane.getVerticalScrollBar(); bar.setValue(bar.getValue() - bar.getBlockIncrement()); }
private void scrollOffset(int more) { myAtEnd = false; int val = myScrollPane.getVerticalScrollBar().getValue(); myScrollPane.getVerticalScrollBar().setValue(val + more); myScrollPane.getHorizontalScrollBar().setValue(0); if (val + more >= myScrollPane.getVerticalScrollBar().getMaximum() - myScrollPane.getVerticalScrollBar().getVisibleAmount()) { myAtEnd = true; myLabel.setText("Hit ENTER or type command to continue"); } else { myLabel.setText("-- MORE --"); } }
void openConfigList() { if (showingPluginList) { scrollBarPosition = scrollPane.getVerticalScrollBar().getValue(); } showingPluginList = true; topPanel.removeAll(); mainPanel.removeAll(); topPanel.add(searchBar, BorderLayout.CENTER); onSearchBarChanged(); searchBar.requestFocusInWindow(); validate(); scrollPane.getVerticalScrollBar().setValue(scrollBarPosition); }
public void refreshImage(boolean external) { final JScrollBar bar1 = scrollPane.getVerticalScrollBar(); final JScrollBar bar2 = scrollPane.getHorizontalScrollBar(); if (external && isError() == false) { v1 = bar1.getValue(); v2 = bar2.getValue(); } scrollPane.setViewportView(buildScrollablePicture()); force(); if (external) { SwingUtilities.invokeLater(new Runnable() { public void run() { refreshSimpleLine(); if (isError() == false) { bar1.setValue(v1); bar2.setValue(v2); } } }); } }
@Override public void adjustmentValueChanged(AdjustmentEvent e) { String content = textArea.getText(); if (content == null || content.length() == 0) return; int scrollValue = verticalScrollbar.getValue() - verticalScrollbar.getMinimum(); int scrollMax = verticalScrollbar.getMaximum() - verticalScrollbar.getMinimum(); if (scrollMax < 1 || scrollValue < 0 || scrollValue > scrollMax) return; lastScrollPercent = (((double) scrollValue) / ((double) scrollMax)); } });
@Override public void adjustmentValueChanged(AdjustmentEvent e) { if (vertical.getValue() >= lastMaximum) { vertical.setValue(actualMax()); } lastMaximum = actualMax(); } });
private void imageLeft() { final JScrollBar bar = scrollPane.getHorizontalScrollBar(); bar.setValue(bar.getValue() - bar.getBlockIncrement()); }
private void imageRight() { final JScrollBar bar = scrollPane.getHorizontalScrollBar(); bar.setValue(bar.getValue() + bar.getBlockIncrement()); }
int value = scrollBar.getValue(); int maximum = scrollBar.getMaximum(); int visibleAmount = scrollBar.getVisibleAmount(); if(lastMaximum < maximum && lastMaximum - visibleAmount - value == 0) { value = scrollBar.getValue() + (maximum - lastMaximum); scrollBar.setVisibleAmount(visibleAmount); if(scrollBar.getValue() != value) { scrollBar.setValue(value);
direction); if (direction < 0) { scrollMin = Math.max(scrollMin, toScroll.getValue() - blockIncr); } else { scrollMax = Math.min(scrollMax, toScroll.getValue() + blockIncr); toScroll.setValue(viewRect.x); } else { int newPos = toScroll.getValue() - (viewRect.x - startingX); if (newPos < scrollMin) { newPos = scrollMin; limit = toScroll.getValue() - toScroll.getBlockIncrement(direction); } else { limit = toScroll.getValue() + toScroll.getBlockIncrement(direction); delta = -toScroll.getUnitIncrement(direction); int oldValue = toScroll.getValue(); int newValue = oldValue + delta; if (delta > 0 && newValue < oldValue) { int oldValue = toScroll.getValue(); int blockIncrement = toScroll.getBlockIncrement(direction); int delta = blockIncrement * ((direction > 0) ? +1 : -1);
scrollBarPosition = scrollPane.getVerticalScrollBar().getValue(); topPanel.removeAll(); mainPanel.removeAll();
JScrollBar vertical = v.getVerticalScrollBar(); int extent = vertical.getModel().getExtent(); boolean isScrollBarAtEnd = vertical.getValue() >= vertical.getMaximum() - extent;
final JScrollBar scrollBar = myScrollpane.getVerticalScrollBar(); scrollBar.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { System.out.println("JScrollBar's current value = " + scrollBar.getValue()); } });
/** * Checks if the scroll position is at the end of the document, with * some margin or error. * * @return true if scroll position is at the end, false otherwise */ private boolean isScrollPositionNearEnd() { JScrollBar vbar = scrollpane.getVerticalScrollBar(); return vbar.getMaximum() - 20 <= vbar.getValue() + vbar.getVisibleAmount(); }
@Override public void actionPerformed (ActionEvent e) { final JScrollBar horizontal = component.getHorizontalScrollBar(); horizontal.setValue(horizontal.getValue() - 1); }
@Override public void actionPerformed (ActionEvent e) { final JScrollBar horizontal = component.getHorizontalScrollBar(); horizontal.setValue(horizontal.getValue() + 1); }
scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent event) { JScrollBar scrollBar = (JScrollBar) event.getAdjustable(); int extent = scrollBar.getModel().getExtent(); System.out.println("1. Value: " + (scrollBar.getValue() + extent) + " Max: " + scrollBar.getMaximum()); } });