ScrollPane.java revision 243
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * This code is free software; you can redistribute it and/or modify it
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * under the terms of the GNU General Public License version 2 only, as
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * published by the Free Software Foundation. Sun designates this
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * particular file as subject to the "Classpath" exception as provided
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * by Sun in the LICENSE file that accompanied this code.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * This code is distributed in the hope that it will be useful, but WITHOUT
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * version 2 for more details (a copy is included in the LICENSE file that
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * accompanied this code).
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * You should have received a copy of the GNU General Public License version
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * 2 along with this work; if not, write to the Free Software Foundation,
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * CA 95054 USA or visit www.sun.com if you need additional information or
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * have any questions.
2d2a52253051eb056ca017546a076c0f585283f2stephh * A container class which implements automatic horizontal and/or
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * vertical scrolling for a single child component. The display
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * policy for the scrollbars can be set to:
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * <LI>as needed: scrollbars created and shown only when needed by scrollpane
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * <LI>always: scrollbars created and always shown by the scrollpane
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * <LI>never: scrollbars never created or shown by the scrollpane
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * The state of the horizontal and vertical scrollbars is represented
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * by two <code>ScrollPaneAdjustable</code> objects (one for each
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * dimension) which implement the <code>Adjustable</code> interface.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * The API provides methods to access those objects such that the
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * attributes on the Adjustable object (such as unitIncrement, value,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * etc.) can be manipulated.
2d2a52253051eb056ca017546a076c0f585283f2stephh * Certain adjustable properties (minimum, maximum, blockIncrement,
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * and visibleAmount) are set internally by the scrollpane in accordance
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * with the geometry of the scrollpane and its child and these should
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * not be set by programs using the scrollpane.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * If the scrollbar display policy is defined as "never", then the
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * scrollpane can still be programmatically scrolled using the
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * setScrollPosition() method and the scrollpane will move and clip
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * the child's contents appropriately. This policy is useful if the
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * program needs to create and manage its own adjustable controls.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * The placement of the scrollbars is controlled by platform-specific
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * properties set by the user outside of the program.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * The initial size of this container is set to 100x100, but can
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * be reset using setSize().
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Scrolling with the wheel on a wheel-equipped mouse is enabled by default.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * This can be disabled using <code>setWheelScrollingEnabled</code>.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Wheel scrolling can be customized by setting the block and
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * unit increment of the horizontal and vertical Adjustables.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * For information on how mouse wheel events are dispatched, see
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * the class description for {@link MouseWheelEvent}.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Insets are used to define any space used by scrollbars and any
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * borders created by the scroll pane. getInsets() can be used
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * to get the current value for the insets. If the value of
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * scrollbarsAlwaysVisible is false, then the value of the insets
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * will change dynamically depending on whether the scrollbars are
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * currently visible or not.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @author Tom Ball
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @author Amy Fowler
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @author Tim Prinzing
2d2a52253051eb056ca017546a076c0f585283f2stephhpublic class ScrollPane extends Container implements Accessible {
2d2a52253051eb056ca017546a076c0f585283f2stephh * Initialize JNI field and method IDs
2d2a52253051eb056ca017546a076c0f585283f2stephh private static native void initIDs();
2d2a52253051eb056ca017546a076c0f585283f2stephh /* ensure that the necessary native libraries are loaded */
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Specifies that horizontal/vertical scrollbar should be shown
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * only when the size of the child exceeds the size of the scrollpane
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * in the horizontal/vertical dimension.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Specifies that horizontal/vertical scrollbars should always be
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * shown regardless of the respective sizes of the scrollpane and child.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Specifies that horizontal/vertical scrollbars should never be shown
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * regardless of the respective sizes of the scrollpane and child.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * There are 3 ways in which a scroll bar can be displayed.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * This integer will represent one of these 3 displays -
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * (SCROLLBARS_ALWAYS, SCROLLBARS_AS_NEEDED, SCROLLBARS_NEVER)
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @see #getScrollbarDisplayPolicy
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * An adjustable vertical scrollbar.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * It is important to note that you must <em>NOT</em> call 3
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * <code>Adjustable</code> methods, namely:
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * <code>setMinimum()</code>, <code>setMaximum()</code>,
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * <code>setVisibleAmount()</code>.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @see #getVAdjustable
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * An adjustable horizontal scrollbar.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * It is important to note that you must <em>NOT</em> call 3
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * <code>Adjustable</code> methods, namely:
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * <code>setMinimum()</code>, <code>setMaximum()</code>,
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * <code>setVisibleAmount()</code>.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @see #getHAdjustable
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows private static final boolean defaultWheelScroll = true;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Indicates whether or not scrolling should take place when a
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * MouseWheelEvent is received.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @since 1.4
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows private boolean wheelScrollingEnabled = defaultWheelScroll;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * JDK 1.1 serialVersionUID
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows private static final long serialVersionUID = 7956609840827222915L;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Create a new scrollpane container with a scrollbar display
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * policy of "as needed".
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @throws HeadlessException if GraphicsEnvironment.isHeadless()
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * returns true
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @see java.awt.GraphicsEnvironment#isHeadless
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Create a new scrollpane container.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @param scrollbarDisplayPolicy policy for when scrollbars should be shown
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @throws IllegalArgumentException if the specified scrollbar
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * display policy is invalid
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @throws HeadlessException if GraphicsEnvironment.isHeadless()
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * returns true
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @see java.awt.GraphicsEnvironment#isHeadless
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows public ScrollPane(int scrollbarDisplayPolicy) throws HeadlessException {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows this.scrollbarDisplayPolicy = scrollbarDisplayPolicy;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows throw new IllegalArgumentException("illegal scrollbar display policy");
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows vAdjustable = new ScrollPaneAdjustable(this, new PeerFixer(this),
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows hAdjustable = new ScrollPaneAdjustable(this, new PeerFixer(this),
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Construct a name for this component. Called by getName() when the
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * name is null.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows synchronized (ScrollPane.class) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // The scrollpane won't work with a windowless child... it assumes
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // it is moving a child window around so the windowless child is
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // wrapped with a window.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows private void addToPanel(Component comp, Object constraints, int index) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Adds the specified component to this scroll pane container.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * If the scroll pane has an existing child component, that
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * component is removed and the new one is added.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @param comp the component to be added
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @param constraints not applicable
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @param index position of child component (must be <= 0)
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows protected final void addImpl(Component comp, Object constraints, int index) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows synchronized (getTreeLock()) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows throw new IllegalArgumentException("position greater than 0");
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Returns the display policy for the scrollbars.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @return the display policy for the scrollbars
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Returns the current size of the scroll pane's view port.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @return the size of the view port in pixels
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Returns the height that would be occupied by a horizontal
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * scrollbar, which is independent of whether it is currently
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * displayed by the scroll pane or not.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @return the height of a horizontal scrollbar in pixels
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Returns the width that would be occupied by a vertical
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * scrollbar, which is independent of whether it is currently
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * displayed by the scroll pane or not.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @return the width of a vertical scrollbar in pixels
2d2a52253051eb056ca017546a076c0f585283f2stephh * Returns the <code>ScrollPaneAdjustable</code> object which
2d2a52253051eb056ca017546a076c0f585283f2stephh * represents the state of the vertical scrollbar.
2d2a52253051eb056ca017546a076c0f585283f2stephh * The declared return type of this method is
2d2a52253051eb056ca017546a076c0f585283f2stephh * <code>Adjustable</code> to maintain backward compatibility.
2d2a52253051eb056ca017546a076c0f585283f2stephh * @see java.awt.ScrollPaneAdjustable
2d2a52253051eb056ca017546a076c0f585283f2stephh * Returns the <code>ScrollPaneAdjustable</code> object which
2d2a52253051eb056ca017546a076c0f585283f2stephh * represents the state of the horizontal scrollbar.
2d2a52253051eb056ca017546a076c0f585283f2stephh * The declared return type of this method is
2d2a52253051eb056ca017546a076c0f585283f2stephh * <code>Adjustable</code> to maintain backward compatibility.
2d2a52253051eb056ca017546a076c0f585283f2stephh * @see java.awt.ScrollPaneAdjustable
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Scrolls to the specified position within the child component.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * A call to this method is only valid if the scroll pane contains
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * a child. Specifying a position outside of the legal scrolling bounds
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * of the child will scroll to the closest legal position.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Legal bounds are defined to be the rectangle:
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * x = 0, y = 0, width = (child width - view port width),
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * height = (child height - view port height).
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * This is a convenience method which interfaces with the Adjustable
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * objects which represent the state of the scrollbars.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @param x the x position to scroll to
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @param y the y position to scroll to
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @throws NullPointerException if the scrollpane does not contain
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows public void setScrollPosition(int x, int y) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows synchronized (getTreeLock()) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Scrolls to the specified position within the child component.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * A call to this method is only valid if the scroll pane contains
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * a child and the specified position is within legal scrolling bounds
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * of the child. Specifying a position outside of the legal scrolling
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * bounds of the child will scroll to the closest legal position.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Legal bounds are defined to be the rectangle:
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * x = 0, y = 0, width = (child width - view port width),
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * height = (child height - view port height).
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * This is a convenience method which interfaces with the Adjustable
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * objects which represent the state of the scrollbars.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @param p the Point representing the position to scroll to
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Returns the current x,y position within the child which is displayed
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * at the 0,0 location of the scrolled panel's view port.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * This is a convenience method which interfaces with the adjustable
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * objects which represent the state of the scrollbars.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @return the coordinate position for the current scroll position
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @throws NullPointerException if the scrollpane does not contain
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows return new Point(hAdjustable.getValue(), vAdjustable.getValue());
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Sets the layout manager for this container. This method is
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * overridden to prevent the layout mgr from being set.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @param mgr the specified layout manager
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Lays out this container by resizing its child to its preferred size.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * If the new preferred size of the child causes the current scroll
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * position to be invalid, the scroll position is set to the closest
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * valid position.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @see Component#validate
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows public void doLayout() {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Determine the size to allocate the child component.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * If the viewport area is bigger than the childs
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * preferred size then the child is allocated enough
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * to fill the viewport, otherwise the child is given
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * it's preferred size.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // calculate the view size, accounting for border but not scrollbars
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // - don't use right/bottom insets since they vary depending
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // on whether or not scrollbars were displayed on last resize
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // determine whether or not horz or vert scrollbars will be displayed
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows Dimension childSize = new Dimension(child.getPreferredSize());
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows if (scrollbarDisplayPolicy == SCROLLBARS_AS_NEEDED) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows } else if (scrollbarDisplayPolicy == SCROLLBARS_ALWAYS) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows } else { // SCROLLBARS_NEVER
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // adjust predicted view size to account for scrollbars
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // if child is smaller than view, size it up
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @deprecated As of JDK version 1.1,
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * replaced by <code>doLayout()</code>.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows public void layout() {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows c.reshape(i.left - p.x, i.top - p.y, cs.width, cs.height);
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // update adjustables... the viewport size may have changed
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // with the scrollbars coming or going so the viewport size
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // is updated before the adjustables.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Prints the component in this scroll pane.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @param g the specified Graphics window
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @see Component#print
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @see Component#printAll
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows } finally {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Creates the scroll pane's peer.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows public void addNotify() {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows synchronized (getTreeLock()) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // Bug 4124460. Save the current adjustable values,
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // so they can be restored after addnotify. Set the
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows // adjustables to 0, to prevent crashes for possible
super.addNotify();
switch (scrollbarDisplayPolicy) {
case SCROLLBARS_AS_NEEDED:
case SCROLLBARS_ALWAYS:
case SCROLLBARS_NEVER:
if (isWheelScrollingEnabled()) {
e.consume();
super.processMouseWheelEvent(e);
public boolean isWheelScrollingEnabled() {
return wheelScrollingEnabled;
s.defaultWriteObject();
return accessibleContext;