/** * Determines when the vertical scrollbar appears in the scrollpane. * The options are: * <li><code>SScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED</code></li> * <li><code>SScrollPane.VERTICAL_SCROLLBAR_NEVER</code></li> * <li><code>SScrollPane.VERTICAL_SCROLLBAR_ALWAYS</code></li> */ public void setVerticalScrollBarPolicy(int policy) { if (policy != verticalScrollBarPolicy) { int oldVal = this.verticalScrollBarPolicy; verticalScrollBarPolicy = policy; adoptScrollBarVisibility(verticalScrollBar, policy); reload(); propertyChangeSupport.firePropertyChange("verticalScrollBarPolicy", oldVal, this.verticalScrollBarPolicy); } }
/** * Determines when the horizontal scrollbar appears in the scrollpane. * The options are: * <li><code>SScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED</code></li> * <li><code>SScrollPane.HORIZONTAL_SCROLLBAR_NEVER</code></li> * <li><code>SScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS</code></li> */ public void setHorizontalScrollBarPolicy(int policy) { if (policy != horizontalScrollBarPolicy) { int oldVal = this.horizontalScrollBarPolicy; horizontalScrollBarPolicy = policy; adoptScrollBarVisibility(horizontalScrollBar, policy); reload(); propertyChangeSupport.firePropertyChange("horizontalScrollBar", oldVal, this.horizontalScrollBarPolicy); } }
@Override public void setExtent(int newExtent) { if (!isViewportAvailable()) return; Rectangle curVp = scrollable.getViewportSize(); Rectangle newVp = (Rectangle)curVp.clone(); if (horizontal && curVp.width != newExtent) { // Keep extent in sync with scrollpane if (horizontalExtent != newExtent) { horizontalExtent = newExtent; SScrollPane.this.reload(); } newVp.width = newExtent; updateViews(newVp); } else if (!horizontal && curVp.height != newExtent) { // Keep extent in sync with scrollpane if (verticalExtent != newExtent) { verticalExtent = newExtent; SScrollPane.this.reload(); } newVp.height = newExtent; updateViews(newVp); } }
/** * Sets the element which should be scrolled. * * @param c the element which should be scrolled. */ protected void setScrollable(SComponent c) { Scrollable oldVal = this.scrollable; if (scrollable != null) { // reset the scrollable's viewport to the one // it had before adding it to this scrollpane scrollable.setViewportSize(backupViewport); } if (c instanceof Scrollable) { scrollable = (Scrollable) c; horizontalModel.setScrollable(scrollable); verticalModel.setScrollable(scrollable); // keep the scrollable's original viewport - the // one it had before adding it to this scrollpane backupViewport = scrollable.getViewportSize(); // apply new viewport to scrollable setInitialViewportSize(); } else { scrollable = null; } reload(); propertyChangeSupport.firePropertyChange("scrollable", oldVal, this.scrollable); }
reload(); propertyChangeSupport.firePropertyChange("horizontalScrollBar", oldVal, this.horizontalScrollBar);
reload(); propertyChangeSupport.firePropertyChange("verticalScrollBar", oldVal, this.verticalScrollBar);