List of utility methods to do JViewport
boolean | canHScroll(JViewport viewport) can H Scroll JScrollPane scrollPane = (JScrollPane) viewport.getParent(); Rectangle availR = scrollPane.getBounds(); Component view = viewport.getView(); Dimension viewPrefSize = view != null ? view.getPreferredSize() : new Dimension(0, 0); Dimension extentSize = viewport.toViewCoordinates(availR.getSize()); boolean canHScroll = true; if (view instanceof Scrollable) canHScroll = !((Scrollable) view).getScrollableTracksViewportWidth(); ... |
boolean | canScroll(JViewport viewport) can Scroll return canHScroll(viewport) || canVScroll(viewport);
|
void | fixScrollRendering(JViewport viewport) fix Scroll Rendering viewport.setScrollMode(JViewport.SIMPLE_SCROLL_MODE); |
void | setViewPortPosition(JViewport viewport, Rectangle position) set View Port Position Point pt = viewport.getViewPosition(); position.setLocation(position.x - pt.x, position.y - pt.y); viewport.scrollRectToVisible(position); |
void | synchronizeView(final JViewport masterViewport, final JViewport slaveViewport, final int orientation) synchronize View final ChangeListener c1 = new ChangeListener() { public void stateChanged(ChangeEvent e) { if (masterViewport.getView() == null || slaveViewport.getView() == null) { return; if (orientation == SwingConstants.HORIZONTAL) { Point v1 = masterViewport.getViewPosition(); Point v2 = slaveViewport.getViewPosition(); ... |