src/share/classes/java/awt/ScrollPane.java

Print this page


   1 /*
   2  * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 307      * displayed by the scroll pane or not.
 308      * @return the width of a vertical scrollbar in pixels
 309      */
 310     public int getVScrollbarWidth() {
 311         int w = 0;
 312         if (scrollbarDisplayPolicy != SCROLLBARS_NEVER) {
 313             ScrollPanePeer peer = (ScrollPanePeer)this.peer;
 314             if (peer != null) {
 315                 w = peer.getVScrollbarWidth();
 316             }
 317         }
 318         return w;
 319     }
 320 
 321     /**
 322      * Returns the <code>ScrollPaneAdjustable</code> object which
 323      * represents the state of the vertical scrollbar.
 324      * The declared return type of this method is
 325      * <code>Adjustable</code> to maintain backward compatibility.
 326      * @see java.awt.ScrollPaneAdjustable

 327      */
 328     public Adjustable getVAdjustable() {
 329         return vAdjustable;
 330     }
 331 
 332     /**
 333      * Returns the <code>ScrollPaneAdjustable</code> object which
 334      * represents the state of the horizontal scrollbar.
 335      * The declared return type of this method is
 336      * <code>Adjustable</code> to maintain backward compatibility.
 337      * @see java.awt.ScrollPaneAdjustable

 338      */
 339     public Adjustable getHAdjustable() {
 340         return hAdjustable;
 341     }
 342 
 343     /**
 344      * Scrolls to the specified position within the child component.
 345      * A call to this method is only valid if the scroll pane contains
 346      * a child.  Specifying a position outside of the legal scrolling bounds
 347      * of the child will scroll to the closest legal position.
 348      * Legal bounds are defined to be the rectangle:
 349      * x = 0, y = 0, width = (child width - view port width),
 350      * height = (child height - view port height).
 351      * This is a convenience method which interfaces with the Adjustable
 352      * objects which represent the state of the scrollbars.
 353      * @param x the x position to scroll to
 354      * @param y the y position to scroll to
 355      * @throws NullPointerException if the scrollpane does not contain
 356      *     a child
 357      */


 639 
 640     /**
 641      * Enables/disables scrolling in response to movement of the mouse wheel.
 642      * Wheel scrolling is enabled by default.
 643      *
 644      * @param handleWheel   <code>true</code> if scrolling should be done
 645      *                      automatically for a MouseWheelEvent,
 646      *                      <code>false</code> otherwise.
 647      * @see #isWheelScrollingEnabled
 648      * @see java.awt.event.MouseWheelEvent
 649      * @see java.awt.event.MouseWheelListener
 650      * @since 1.4
 651      */
 652     public void setWheelScrollingEnabled(boolean handleWheel) {
 653         wheelScrollingEnabled = handleWheel;
 654     }
 655 
 656     /**
 657      * Indicates whether or not scrolling will take place in response to
 658      * the mouse wheel.  Wheel scrolling is enabled by default.



 659      *
 660      * @see #setWheelScrollingEnabled(boolean)
 661      * @since 1.4
 662      */
 663     public boolean isWheelScrollingEnabled() {
 664         return wheelScrollingEnabled;
 665     }
 666 
 667 
 668     /**
 669      * Writes default serializable fields to stream.
 670      */
 671     private void writeObject(ObjectOutputStream s) throws IOException {
 672         // 4352819: We only need this degenerate writeObject to make
 673         // it safe for future versions of this class to write optional
 674         // data to the stream.
 675         s.defaultWriteObject();
 676     }
 677 
 678     /**


   1 /*
   2  * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 307      * displayed by the scroll pane or not.
 308      * @return the width of a vertical scrollbar in pixels
 309      */
 310     public int getVScrollbarWidth() {
 311         int w = 0;
 312         if (scrollbarDisplayPolicy != SCROLLBARS_NEVER) {
 313             ScrollPanePeer peer = (ScrollPanePeer)this.peer;
 314             if (peer != null) {
 315                 w = peer.getVScrollbarWidth();
 316             }
 317         }
 318         return w;
 319     }
 320 
 321     /**
 322      * Returns the <code>ScrollPaneAdjustable</code> object which
 323      * represents the state of the vertical scrollbar.
 324      * The declared return type of this method is
 325      * <code>Adjustable</code> to maintain backward compatibility.
 326      * @see java.awt.ScrollPaneAdjustable
 327      * @return  the vertical scrollbar state
 328      */
 329     public Adjustable getVAdjustable() {
 330         return vAdjustable;
 331     }
 332 
 333     /**
 334      * Returns the <code>ScrollPaneAdjustable</code> object which
 335      * represents the state of the horizontal scrollbar.
 336      * The declared return type of this method is
 337      * <code>Adjustable</code> to maintain backward compatibility.
 338      * @see java.awt.ScrollPaneAdjustable
 339      * @return  the horizontal scrollbar state
 340      */
 341     public Adjustable getHAdjustable() {
 342         return hAdjustable;
 343     }
 344 
 345     /**
 346      * Scrolls to the specified position within the child component.
 347      * A call to this method is only valid if the scroll pane contains
 348      * a child.  Specifying a position outside of the legal scrolling bounds
 349      * of the child will scroll to the closest legal position.
 350      * Legal bounds are defined to be the rectangle:
 351      * x = 0, y = 0, width = (child width - view port width),
 352      * height = (child height - view port height).
 353      * This is a convenience method which interfaces with the Adjustable
 354      * objects which represent the state of the scrollbars.
 355      * @param x the x position to scroll to
 356      * @param y the y position to scroll to
 357      * @throws NullPointerException if the scrollpane does not contain
 358      *     a child
 359      */


 641 
 642     /**
 643      * Enables/disables scrolling in response to movement of the mouse wheel.
 644      * Wheel scrolling is enabled by default.
 645      *
 646      * @param handleWheel   <code>true</code> if scrolling should be done
 647      *                      automatically for a MouseWheelEvent,
 648      *                      <code>false</code> otherwise.
 649      * @see #isWheelScrollingEnabled
 650      * @see java.awt.event.MouseWheelEvent
 651      * @see java.awt.event.MouseWheelListener
 652      * @since 1.4
 653      */
 654     public void setWheelScrollingEnabled(boolean handleWheel) {
 655         wheelScrollingEnabled = handleWheel;
 656     }
 657 
 658     /**
 659      * Indicates whether or not scrolling will take place in response to
 660      * the mouse wheel.  Wheel scrolling is enabled by default.
 661      *
 662      * @return  {@code true} if the wheel scrolling enabled;
 663      *          otherwise {@code false}
 664      *
 665      * @see #setWheelScrollingEnabled(boolean)
 666      * @since 1.4
 667      */
 668     public boolean isWheelScrollingEnabled() {
 669         return wheelScrollingEnabled;
 670     }
 671 
 672 
 673     /**
 674      * Writes default serializable fields to stream.
 675      */
 676     private void writeObject(ObjectOutputStream s) throws IOException {
 677         // 4352819: We only need this degenerate writeObject to make
 678         // it safe for future versions of this class to write optional
 679         // data to the stream.
 680         s.defaultWriteObject();
 681     }
 682 
 683     /**