Java Code Examples for javax.swing.JScrollBar#getMaximum()
The following examples show how to use
javax.swing.JScrollBar#getMaximum() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Test6526631.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 2
Source File: Test6526631.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 3
Source File: Test6526631.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 4
Source File: Test6526631.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 5
Source File: SeaGlassScrollPaneUI.java From seaglass with Apache License 2.0 | 6 votes |
void scrollByBlock(JScrollBar scrollbar, int direction) { // This method is called from BasicScrollPaneUI to implement wheel // scrolling, and also from scrollByBlock(). int oldValue = scrollbar.getValue(); int blockIncrement = scrollbar.getBlockIncrement(direction); int delta = blockIncrement * ((direction > 0) ? +1 : -1); int newValue = oldValue + delta; // Check for overflow. if (delta > 0 && newValue < oldValue) { newValue = scrollbar.getMaximum(); } else if (delta < 0 && newValue > oldValue) { newValue = scrollbar.getMinimum(); } scrollbar.setValue(newValue); }
Example 6
Source File: Test6526631.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 7
Source File: Test6526631.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 8
Source File: Test6526631.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 9
Source File: Test6526631.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 10
Source File: Test6526631.java From hottub with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 11
Source File: Test6526631.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 12
Source File: Test6526631.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 13
Source File: Test6526631.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 14
Source File: EULADialog.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Listens to changes of the scroll bar of the text are showing the EULA text, enables the check * box once the user scrolled to the end of the document. */ @Override public void adjustmentValueChanged(AdjustmentEvent e) { JScrollBar scrollBar = this.scrollPane.getVerticalScrollBar(); if (e.getSource() == scrollBar) { // the maximum value of the scroll bar assumes that the content is // not visible anymore, since this is not the case when scrolling // to the end of the document (the last part is still visible), // we have to include the visible amount in the comparison int currentValue = scrollBar.getValue() + scrollBar.getVisibleAmount(); if (currentValue >= scrollBar.getMaximum()) { // the user scrolled to the end of the document this.acceptCheckBox.setEnabled(true); this.acceptCheckBox.requestFocusInWindow(); } } }
Example 15
Source File: Test6526631.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public void validateThird() { JViewport viewport = this.pane.getViewport(); JScrollBar scroller = this.pane.getHorizontalScrollBar(); if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { throw new Error("unexpected component orientation"); } int value = scroller.getValue(); if (value != 0) { throw new Error("unexpected scroll value"); } int extent = viewport.getExtentSize().width; if (extent != scroller.getVisibleAmount()) { throw new Error("unexpected visible amount"); } int size = viewport.getViewSize().width; if (size != scroller.getMaximum()) { throw new Error("unexpected maximum"); } int pos = size - extent - value; if (pos != viewport.getViewPosition().x) { throw new Error("unexpected position"); } }
Example 16
Source File: AppStoreListBuilder.java From raccoon4 with Apache License 2.0 | 5 votes |
@Override public void adjustmentValueChanged(AdjustmentEvent e) { if (e.getSource() instanceof JScrollBar) { JScrollBar bar = (JScrollBar) e.getSource(); if (e.getValue() > (bar.getMaximum() - bar.getModel().getExtent()) * 0.85f) { if (!loading && !padded) { globals.get(PlayManager.class).moreApps(); } } } }
Example 17
Source File: DiscoveryPanel.java From nanoleaf-desktop with MIT License | 5 votes |
private void updateEffectsByScroll(JScrollBar bar) { if (bar.getValue() == bar.getMaximum() - bar.getVisibleAmount() && !isUpdating) { topPage++; updateEffects(); } }
Example 18
Source File: FlatScrollPaneUI.java From FlatLaf with Apache License 2.0 | 4 votes |
private void mouseWheelMovedSmooth( MouseWheelEvent e ) { // return if there is no viewport JViewport viewport = scrollpane.getViewport(); if( viewport == null ) return; // find scrollbar to scroll JScrollBar scrollbar = scrollpane.getVerticalScrollBar(); if( scrollbar == null || !scrollbar.isVisible() || e.isShiftDown() ) { scrollbar = scrollpane.getHorizontalScrollBar(); if( scrollbar == null || !scrollbar.isVisible() ) return; } // consume event e.consume(); // get precise wheel rotation double rotation = e.getPreciseWheelRotation(); // get unit and block increment int unitIncrement; int blockIncrement; int orientation = scrollbar.getOrientation(); Component view = viewport.getView(); if( view instanceof Scrollable ) { Scrollable scrollable = (Scrollable) view; // Use (0, 0) view position to obtain constant unit increment of first item // (which might otherwise be variable on smaller-than-unit scrolling). Rectangle visibleRect = new Rectangle( viewport.getViewSize() ); unitIncrement = scrollable.getScrollableUnitIncrement( visibleRect, orientation, 1 ); blockIncrement = scrollable.getScrollableBlockIncrement( visibleRect, orientation, 1 ); if( unitIncrement > 0 ) { // For the case that the first item (e.g. in a list) is larger // than the other items, get the unit increment of the second item // and use the smaller one. if( orientation == SwingConstants.VERTICAL ) { visibleRect.y += unitIncrement; visibleRect.height -= unitIncrement; } else { visibleRect.x += unitIncrement; visibleRect.width -= unitIncrement; } int unitIncrement2 = scrollable.getScrollableUnitIncrement( visibleRect, orientation, 1 ); if( unitIncrement2 > 0 ) unitIncrement = Math.min( unitIncrement, unitIncrement2 ); } } else { int direction = rotation < 0 ? -1 : 1; unitIncrement = scrollbar.getUnitIncrement( direction ); blockIncrement = scrollbar.getBlockIncrement( direction ); } // limit scroll amount (number of units to scroll) for small viewports // (e.g. vertical scrolling in file chooser) int scrollAmount = e.getScrollAmount(); int viewportWH = (orientation == SwingConstants.VERTICAL) ? viewport.getHeight() : viewport.getWidth(); if( unitIncrement * scrollAmount > viewportWH ) scrollAmount = Math.max( viewportWH / unitIncrement, 1 ); // compute relative delta double delta = rotation * scrollAmount * unitIncrement; boolean adjustDelta = Math.abs( rotation ) < (1.0 + EPSILON); double adjustedDelta = adjustDelta ? Math.max( -blockIncrement, Math.min( delta, blockIncrement ) ) : delta; // compute new value int value = scrollbar.getValue(); double minDelta = scrollbar.getMinimum() - value; double maxDelta = scrollbar.getMaximum() - scrollbar.getModel().getExtent() - value; double boundedDelta = Math.max( minDelta, Math.min( adjustedDelta, maxDelta ) ); int newValue = value + (int) Math.round( boundedDelta ); // set new value if( newValue != value ) scrollbar.setValue( newValue ); /*debug System.out.println( String.format( "%4d %9f / %4d %4d / %12f %5s %12f / %4d %4d %4d / %12f %12f %12f / %4d", e.getWheelRotation(), e.getPreciseWheelRotation(), unitIncrement, blockIncrement, delta, adjustDelta, adjustedDelta, value, scrollbar.getMinimum(), scrollbar.getMaximum(), minDelta, maxDelta, boundedDelta, newValue ) ); */ }
Example 19
Source File: mxGraphOutline.java From blog-codes with Apache License 2.0 | 4 votes |
public void mouseReleased(MouseEvent e) { if (start != null) { if (zoomGesture) { double dx = e.getX() - start.getX(); double w = finderBounds.getWidth(); final JScrollBar hs = graphComponent .getHorizontalScrollBar(); final double sx; if (hs != null) { sx = (double) hs.getValue() / hs.getMaximum(); } else { sx = 0; } final JScrollBar vs = graphComponent.getVerticalScrollBar(); final double sy; if (vs != null) { sy = (double) vs.getValue() / vs.getMaximum(); } else { sy = 0; } mxGraphView view = graphComponent.getGraph().getView(); double scale = view.getScale(); double newScale = scale - (dx * scale) / w; double factor = newScale / scale; view.setScale(newScale); if (hs != null) { hs.setValue((int) (sx * hs.getMaximum() * factor)); } if (vs != null) { vs.setValue((int) (sy * vs.getMaximum() * factor)); } } zoomGesture = false; start = null; } }