@Override public void stateChanged(ChangeEvent e) { JViewport viewPort = (JViewport)e.getSource(); if (lastViewPortWidth != viewPort.getWidth()) { lastViewPortWidth = viewPort.getWidth(); horizontalScrollBar.setBlockIncrement(lastViewPortWidth); } }
int heightMargin = insets.top + insets.bottom; scrollBar.setUnitIncrement(unit); scrollBar.setBlockIncrement(extent); scrollBar.setValues(0, heightMargin + extent, 0, heightMargin + max);
horizontalScrollBar.setBlockIncrement(getViewport().getWidth());
private JScrollPane getScrollPane() { JScrollPane scrollPane = new JScrollPane(); scrollPane.setBorder(new LineBorder(Color.LIGHT_GRAY)); Action blankAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { } }; scrollPane.getActionMap().put("unitScrollDown", blankAction); scrollPane.getActionMap().put("unitScrollLeft", blankAction); scrollPane.getActionMap().put("unitScrollRight", blankAction); scrollPane.getActionMap().put("unitScrollUp", blankAction); JScrollBar verticalScrollBar = scrollPane.createVerticalScrollBar(); verticalScrollBar.setUnitIncrement(HexView.CHAR_HEIGHT); verticalScrollBar.setBlockIncrement(HexView.CHAR_HEIGHT * 20); verticalScrollBar.setValues(0, 1, 0, HexView.CHAR_HEIGHT * (model.totalLine()+1)); scrollPane.setVerticalScrollBar(verticalScrollBar); return scrollPane; }
public void setBlockIncrement(int blockIncrement) { blockIncrementSet = true; super.setBlockIncrement(blockIncrement); }
/** * Sets the block increments of both bars. * * @param inc the increment to use * @see #BLOCK_INCREMENT */ public void setScrollBarBlockIncrement(int inc) { getVerticalScrollBar().setBlockIncrement(inc); getHorizontalScrollBar().setBlockIncrement(inc); } }
public void setPageIncrement(int l) { getSwingComponent().setBlockIncrement(l); }
@Override public void stateChanged(ChangeEvent e) { JViewport viewPort = (JViewport)e.getSource(); if (lastViewPortWidth != viewPort.getWidth()) { lastViewPortWidth = viewPort.getWidth(); horizontalScrollBar.setBlockIncrement(lastViewPortWidth); } }
@Override public void componentResized(ComponentEvent e) { scrollPane.getVerticalScrollBar().setBlockIncrement((int) (scrollPane.getVerticalScrollBar().getModel().getExtent() * 0.95f)); scrollPane.getHorizontalScrollBar().setBlockIncrement((int) (scrollPane.getHorizontalScrollBar().getModel().getExtent() * 0.95f)); } });
/** 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); } });
/** 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); } });
/** 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 createScrollBars() { this.horizontalScrollBar = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 0); this.horizontalScrollBar.setBlockIncrement(this.configurationContext.getCellWidth()); this.horizontalScrollBar.setUnitIncrement(this.configurationContext.getCellWidth()); this.verticalScrollBar = new JScrollBar(JScrollBar.VERTICAL, 0, 0, 0, 0); this.verticalScrollBar.setBlockIncrement(this.configurationContext.getCellHeight()); this.verticalScrollBar.setUnitIncrement(this.configurationContext.getCellHeight()); }
@Override public void run() { final boolean zoomed = rangeMin != 0 || rangeMax != elapsedGameLoops; final double factor = (double) ( elapsedGameLoops + 1 ) / ( rangeMax - rangeMin + 1 ); zoomFactorLabel.setText( Env.LANG.formatNumber( factor, 1 ) + "x" ); chartsCanvasScrollBar.getModel().setRangeProperties( rangeMin, rangeMax - rangeMin, 0, elapsedGameLoops, false ); chartsCanvasScrollBar.setUnitIncrement( Math.max( 1, ( rangeMax - rangeMin ) >> 7 ) ); chartsCanvasScrollBar.setBlockIncrement( Math.max( 1, ( rangeMax - rangeMin ) >> 2 ) ); zoomFactorLabel.setVisible( zoomed ); resetZoomButton.setEnabled( zoomed ); chartsCanvasScrollBar.setVisible( zoomed ); } };
private void revalidateScrollBar() { if (!isDisplayable()) { return; } if (!isTreeHScrollBar) { return ; } if ( (outline.getColumnModel().getColumnCount() > 0) ) { int column = outline.convertColumnIndexToView(0); int extentWidth = outline.getColumnModel().getColumn(column).getWidth(); int maxWidth = outline.getTreePreferredWidth(); int positionX = outline.getTreePositionX(); int value = Math.max(0, Math.min(positionX, maxWidth - extentWidth)); hScrollBar.setValues(value, extentWidth, 0, maxWidth); hScrollBar.setBlockIncrement(extentWidth); } }
void updateMaxHorizontalScrollWidth() { int max = chunkCache.getMaxHorizontalScrollWidth(); if (max != maxHorizontalScrollWidth) { maxHorizontalScrollWidth = max; horizontal .setValues(Math.max( 0, Math.min(maxHorizontalScrollWidth + charWidth - painter.getWidth(), -horizontalOffset)), painter.getWidth(), 0, maxHorizontalScrollWidth + charWidth); horizontal.setUnitIncrement(10); horizontal.setBlockIncrement(painter.getWidth()); } else if (horizontal.getValue() != -horizontalOffset) { horizontal.setValue(-horizontalOffset); } } // }}}
/** * Initializes the Form */ public TelemetryOverviewPanel() { setName(Bundle.LAB_TelemetryOverviewPanelName()); setIcon(windowIcon); setToolTipText(Bundle.TelemetryOverviewPanel_TelemetryOverviewAccessDescr()); graphsPanel = new MonitoringGraphsPanel(); JScrollPane graphsPanelScroll = new JScrollPane(graphsPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); graphsPanelScroll.setBorder(BorderFactory.createEmptyBorder()); graphsPanelScroll.setViewportBorder(BorderFactory.createEmptyBorder()); graphsPanelScroll.getHorizontalScrollBar().setUnitIncrement(20); graphsPanelScroll.getHorizontalScrollBar().setBlockIncrement(20); setLayout(new BorderLayout()); add(graphsPanelScroll, BorderLayout.CENTER); setFocusable(true); setRequestFocusEnabled(true); }
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); } }
/** * Creates a scroll widget. * @param scene */ public SwingScrollWidget (Scene scene) { super (scene); setLayout (new SwingScrollWidget.ScrollLayout ()); setCheckClipping (true); viewport = new Widget (scene); viewport.setCheckClipping (true); addChild (viewport); verticalScroll = new JScrollBar (JScrollBar.VERTICAL); verticalScroll.setUnitIncrement (16); verticalScroll.setBlockIncrement (64); verticalWidget = new ComponentWidget (scene, verticalScroll); horizontalScroll = new JScrollBar (JScrollBar.HORIZONTAL); horizontalScroll.setUnitIncrement (16); horizontalScroll.setBlockIncrement (64); horizontalWidget = new ComponentWidget (scene, horizontalScroll); }
/** * Creates a scroll widget. * @param scene */ public SwingScrollWidget (Scene scene) { super (scene); setLayout (new SwingScrollWidget.ScrollLayout ()); setCheckClipping (true); viewport = new Widget (scene); viewport.setCheckClipping (true); addChild (viewport); verticalScroll = new JScrollBar (JScrollBar.VERTICAL); verticalScroll.setUnitIncrement (16); verticalScroll.setBlockIncrement (64); verticalWidget = new ComponentWidget (scene, verticalScroll); horizontalScroll = new JScrollBar (JScrollBar.HORIZONTAL); horizontalScroll.setUnitIncrement (16); horizontalScroll.setBlockIncrement (64); horizontalWidget = new ComponentWidget (scene, horizontalScroll); }