< prev index next >

src/java.desktop/share/classes/javax/swing/JScrollPane.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2017, 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


  38 
  39 import java.io.ObjectOutputStream;
  40 import java.io.IOException;
  41 
  42 import java.beans.JavaBean;
  43 import java.beans.BeanProperty;
  44 import java.beans.PropertyChangeEvent;
  45 import java.beans.PropertyChangeListener;
  46 import java.beans.Transient;
  47 
  48 /**
  49  * Provides a scrollable view of a lightweight component.
  50  * A <code>JScrollPane</code> manages a viewport, optional
  51  * vertical and horizontal scroll bars, and optional row and
  52  * column heading viewports.
  53  * You can find task-oriented documentation of <code>JScrollPane</code> in
  54  *  <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/scrollpane.html">How to Use Scroll Panes</a>,
  55  * a section in <em>The Java Tutorial</em>.  Note that
  56  * <code>JScrollPane</code> does not support heavyweight components.
  57  *
  58  * <table class="borderless" style="float:right">
  59  * <caption>Example</caption>
  60  *    <TR>
  61  *    <TD style="text-align:center">
  62  *      <P STYLE="TEXT-ALIGN:CENTER"><IMG SRC="doc-files/JScrollPane-1.gif"
  63  *      alt="The following text describes this image."
  64  *      WIDTH="256" HEIGHT="248" STYLE="FLOAT:BOTTOM; BORDER:0px">
  65  *    </TD>
  66  *    </TR>
  67  * </TABLE>
  68  * The <code>JViewport</code> provides a window,
  69  * or &quot;viewport&quot; onto a data
  70  * source -- for example, a text file. That data source is the
  71  * &quot;scrollable client&quot; (aka data model) displayed by the
  72  * <code>JViewport</code> view.
  73  * A <code>JScrollPane</code> basically consists of <code>JScrollBar</code>s,
  74  * a <code>JViewport</code>, and the wiring between them,
  75  * as shown in the diagram at right.
  76  * <p>
  77  * In addition to the scroll bars and viewport,
  78  * a <code>JScrollPane</code> can have a
  79  * column header and a row header. Each of these is a
  80  * <code>JViewport</code> object that
  81  * you specify with <code>setRowHeaderView</code>,
  82  * and <code>setColumnHeaderView</code>.
  83  * The column header viewport automatically scrolls left and right, tracking
  84  * the left-right scrolling of the main viewport.
  85  * (It never scrolls vertically, however.)
  86  * The row header acts in a similar fashion.
  87  * <p>


   1 /*
   2  * Copyright (c) 1997, 2019, 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


  38 
  39 import java.io.ObjectOutputStream;
  40 import java.io.IOException;
  41 
  42 import java.beans.JavaBean;
  43 import java.beans.BeanProperty;
  44 import java.beans.PropertyChangeEvent;
  45 import java.beans.PropertyChangeListener;
  46 import java.beans.Transient;
  47 
  48 /**
  49  * Provides a scrollable view of a lightweight component.
  50  * A <code>JScrollPane</code> manages a viewport, optional
  51  * vertical and horizontal scroll bars, and optional row and
  52  * column heading viewports.
  53  * You can find task-oriented documentation of <code>JScrollPane</code> in
  54  *  <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/scrollpane.html">How to Use Scroll Panes</a>,
  55  * a section in <em>The Java Tutorial</em>.  Note that
  56  * <code>JScrollPane</code> does not support heavyweight components.
  57  *
  58  * <div style="float:right;text-align:center;font-weight:bold">
  59  *   <p>Example:
  60  *   <p><img src="doc-files/JScrollPane-1.gif"


  61  *       alt="The following text describes this image."
  62  *       width="256" height="248" style="float:bottom; border:0px">
  63  * </div>


  64  * The <code>JViewport</code> provides a window,
  65  * or &quot;viewport&quot; onto a data
  66  * source -- for example, a text file. That data source is the
  67  * &quot;scrollable client&quot; (aka data model) displayed by the
  68  * <code>JViewport</code> view.
  69  * A <code>JScrollPane</code> basically consists of <code>JScrollBar</code>s,
  70  * a <code>JViewport</code>, and the wiring between them,
  71  * as shown in the diagram at right.
  72  * <p>
  73  * In addition to the scroll bars and viewport,
  74  * a <code>JScrollPane</code> can have a
  75  * column header and a row header. Each of these is a
  76  * <code>JViewport</code> object that
  77  * you specify with <code>setRowHeaderView</code>,
  78  * and <code>setColumnHeaderView</code>.
  79  * The column header viewport automatically scrolls left and right, tracking
  80  * the left-right scrolling of the main viewport.
  81  * (It never scrolls vertically, however.)
  82  * The row header acts in a similar fashion.
  83  * <p>


< prev index next >