Java Utililty Methods JViewport

List of utility methods to do JViewport

Description

The list of methods to do JViewport are organized into topic(s).

Method

booleancanHScroll(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();
...
booleancanScroll(JViewport viewport)
can Scroll
return canHScroll(viewport) || canVScroll(viewport);
voidfixScrollRendering(JViewport viewport)
fix Scroll Rendering
viewport.setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
voidsetViewPortPosition(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);
voidsynchronizeView(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();
...