public void run() { jScrollPane.getVerticalScrollBar().setValue(0); } });
: (event.getWheelRotation() < 0 ? -1 : 1) * scrollBar.getBlockIncrement(); scrollBar.setValue(scrollBar.getValue() + amount); event.consume();
JScrollBar vertical = scrollPane.getVerticalScrollBar(); vertical.setValue( vertical.getMaximum() );
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 --"); } }
private void imageUp() { final JScrollBar bar = scrollPane.getVerticalScrollBar(); bar.setValue(bar.getValue() - bar.getBlockIncrement()); }
private void imageDown() { final JScrollBar bar = scrollPane.getVerticalScrollBar(); bar.setValue(bar.getValue() + bar.getBlockIncrement()); }
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); }
private void showMatchedPart(int idx) { Point2D.Double coord = matchedPartCoordinates.get(idx); Dimension treeSize = tjp.getPreferredSize(); JScrollBar horizontal = scroller.getHorizontalScrollBar(); JScrollBar vertical = scroller.getVerticalScrollBar(); int horizontalLength = horizontal.getMaximum() - horizontal.getMinimum(); double x = Math.max(0, (coord.getX() / treeSize.getWidth() * horizontalLength - (scroller.getWidth() / 2.0))); int verticalLength = vertical.getMaximum() - vertical.getMinimum(); double y = Math.max(0, (coord.getY() / treeSize.getHeight() * verticalLength - (scroller.getHeight() / 2.0))); horizontal.setValue((int) x); vertical.setValue((int) y); }
@Override public void adjustmentValueChanged(AdjustmentEvent e) { if (vertical.getValue() >= lastMaximum) { vertical.setValue(actualMax()); } lastMaximum = actualMax(); } });
private void imageRight() { final JScrollBar bar = scrollPane.getHorizontalScrollBar(); bar.setValue(bar.getValue() + bar.getBlockIncrement()); }
private void imageLeft() { final JScrollBar bar = scrollPane.getHorizontalScrollBar(); bar.setValue(bar.getValue() - bar.getBlockIncrement()); }
public void setWatched(boolean watched) { this.watched = watched; final JScrollBar horizontalScrollBar = ((ModelChartImpl) getLastMaximizedChartPanelView().getModelChart()).getHorizontalScrollBar(); if (watched) { horizontalScrollBar.setValue(horizontalScrollBar.getMaximum()); } horizontalScrollBar.setEnabled(!watched); }
@Override public void run() { JScrollBar verticalScrollbar = scrollPane.getVerticalScrollBar(); if (verticalScrollbar == null) return; int scrollMax = verticalScrollbar.getMaximum() - verticalScrollbar.getMinimum(); long newScrollValue = Math.round(position * scrollMax) + verticalScrollbar.getMinimum(); if (newScrollValue < verticalScrollbar.getMinimum()) newScrollValue = verticalScrollbar.getMinimum(); if (newScrollValue > verticalScrollbar.getMaximum()) newScrollValue = verticalScrollbar.getMaximum(); verticalScrollbar.setValue((int) newScrollValue); } });
private void positionPanel() { final JComponent contentComponent = myEditor.getContentComponent(); Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, contentComponent); setSize(scroll.getSize()); myLineHeight = myText.getFontMetrics(myText.getFont()).getHeight(); int count = countLines(myText.getText()); int visLines = getSize().height / myLineHeight - 1; int lines = Math.min(count, visLines); setSize(getSize().width, lines * myLineHeight + myLabel.getPreferredSize().height + getBorder().getBorderInsets(this).top * 2); int height = getSize().height; Rectangle bounds = scroll.getBounds(); bounds.translate(0, scroll.getHeight() - height); bounds.height = height; Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(), SwingUtilities.getRootPane(contentComponent).getGlassPane()); bounds.setLocation(pos); setBounds(bounds); myScrollPane.getVerticalScrollBar().setValue(0); if (!Options.getInstance().isSet("more")) { // FIX scrollOffset(100000); } else { scrollOffset(0); } }
scrollPane.getVerticalScrollBar().setValue(0);
scrollBar.setValue(value);
/** * Creates a new {@code ScrollingSwingTerminal} with customizable settings. * @param deviceConfiguration How to configure the terminal virtual device * @param fontConfiguration What kind of fonts to use * @param colorConfiguration Which color schema to use for ANSI colors */ @SuppressWarnings({"SameParameterValue", "WeakerAccess"}) public ScrollingSwingTerminal( TerminalEmulatorDeviceConfiguration deviceConfiguration, SwingTerminalFontConfiguration fontConfiguration, TerminalEmulatorColorConfiguration colorConfiguration) { this.scrollBar = new JScrollBar(JScrollBar.VERTICAL); this.swingTerminal = new SwingTerminal( deviceConfiguration, fontConfiguration, colorConfiguration, new ScrollController()); setLayout(new BorderLayout()); add(swingTerminal, BorderLayout.CENTER); add(scrollBar, BorderLayout.EAST); this.scrollBar.setMinimum(0); this.scrollBar.setMaximum(20); this.scrollBar.setValue(0); this.scrollBar.setVisibleAmount(20); this.scrollBar.addAdjustmentListener(new ScrollbarListener()); this.scrollModelUpdateBySystem = false; }
/** * Implement the ChangeListener */ @Override public void stateChanged(ChangeEvent e) { // Sync the scroll pane scrollbar with the row header JViewport viewport = (JViewport) e.getSource(); this.scrollPane.getVerticalScrollBar().setValue(viewport.getViewPosition().y); }
panel.revalidate(); int height = (int)panel.getPreferredSize().getHeight(); scroll.getVerticalScrollBar().setValue(height);