src/share/classes/javax/swing/JViewport.java

Print this page


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


  85  * so this optimization is usually worth the performance hit when obscured.
  86  * <p>
  87  * <strong>Warning:</strong> Swing is not thread safe. For more
  88  * information see <a
  89  * href="package-summary.html#threading">Swing's Threading
  90  * Policy</a>.
  91  * <p>
  92  * <strong>Warning:</strong>
  93  * Serialized objects of this class will not be compatible with
  94  * future Swing releases. The current serialization support is
  95  * appropriate for short term storage or RMI between applications running
  96  * the same version of Swing.  As of 1.4, support for long term storage
  97  * of all JavaBeans&trade;
  98  * has been added to the <code>java.beans</code> package.
  99  * Please see {@link java.beans.XMLEncoder}.
 100  *
 101  * @author Hans Muller
 102  * @author Philip Milne
 103  * @see JScrollPane
 104  */

 105 public class JViewport extends JComponent implements Accessible
 106 {
 107     /**
 108      * @see #getUIClassID
 109      * @see #readObject
 110      */
 111     private static final String uiClassID = "ViewportUI";
 112 
 113     /** Property used to indicate window blitting should not be done.
 114      */
 115     static final Object EnableWindowBlit = "EnableWindowBlit";
 116 
 117     /**
 118      * True when the viewport dimensions have been determined.
 119      * The default is false.
 120      */
 121     protected boolean isViewSizeSet = false;
 122 
 123     /**
 124      * The last <code>viewPosition</code> that we've painted, so we know how


1279     public void setExtentSize(Dimension newExtent) {
1280         Dimension oldExtent = getExtentSize();
1281         if (!newExtent.equals(oldExtent)) {
1282             setSize(newExtent);
1283             fireStateChanged();
1284         }
1285     }
1286 
1287     /**
1288      * A listener for the view.
1289      * <p>
1290      * <strong>Warning:</strong>
1291      * Serialized objects of this class will not be compatible with
1292      * future Swing releases. The current serialization support is
1293      * appropriate for short term storage or RMI between applications running
1294      * the same version of Swing.  As of 1.4, support for long term storage
1295      * of all JavaBeans&trade;
1296      * has been added to the <code>java.beans</code> package.
1297      * Please see {@link java.beans.XMLEncoder}.
1298      */

1299     protected class ViewListener extends ComponentAdapter implements Serializable
1300     {
1301         public void componentResized(ComponentEvent e) {
1302             fireStateChanged();
1303             revalidate();
1304         }
1305     }
1306 
1307     /**
1308      * Creates a listener for the view.
1309      * @return a <code>ViewListener</code>
1310      */
1311     protected ViewListener createViewListener() {
1312         return new ViewListener();
1313     }
1314 
1315 
1316     /**
1317      * Subclassers can override this to install a different
1318      * layout manager (or <code>null</code>) in the constructor.  Returns


1748         if (accessibleContext == null) {
1749             accessibleContext = new AccessibleJViewport();
1750         }
1751         return accessibleContext;
1752     }
1753 
1754     /**
1755      * This class implements accessibility support for the
1756      * <code>JViewport</code> class.  It provides an implementation of the
1757      * Java Accessibility API appropriate to viewport user-interface elements.
1758      * <p>
1759      * <strong>Warning:</strong>
1760      * Serialized objects of this class will not be compatible with
1761      * future Swing releases. The current serialization support is
1762      * appropriate for short term storage or RMI between applications running
1763      * the same version of Swing.  As of 1.4, support for long term storage
1764      * of all JavaBeans&trade;
1765      * has been added to the <code>java.beans</code> package.
1766      * Please see {@link java.beans.XMLEncoder}.
1767      */

1768     protected class AccessibleJViewport extends AccessibleJComponent {
1769         /**
1770          * Get the role of this object.
1771          *
1772          * @return an instance of AccessibleRole describing the role of
1773          * the object
1774          */
1775         public AccessibleRole getAccessibleRole() {
1776             return AccessibleRole.VIEWPORT;
1777         }
1778     } // inner class AccessibleJViewport
1779 }
   1 /*
   2  * Copyright (c) 1997, 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


  85  * so this optimization is usually worth the performance hit when obscured.
  86  * <p>
  87  * <strong>Warning:</strong> Swing is not thread safe. For more
  88  * information see <a
  89  * href="package-summary.html#threading">Swing's Threading
  90  * Policy</a>.
  91  * <p>
  92  * <strong>Warning:</strong>
  93  * Serialized objects of this class will not be compatible with
  94  * future Swing releases. The current serialization support is
  95  * appropriate for short term storage or RMI between applications running
  96  * the same version of Swing.  As of 1.4, support for long term storage
  97  * of all JavaBeans&trade;
  98  * has been added to the <code>java.beans</code> package.
  99  * Please see {@link java.beans.XMLEncoder}.
 100  *
 101  * @author Hans Muller
 102  * @author Philip Milne
 103  * @see JScrollPane
 104  */
 105 @SuppressWarnings("serial") // Same-version serialization only
 106 public class JViewport extends JComponent implements Accessible
 107 {
 108     /**
 109      * @see #getUIClassID
 110      * @see #readObject
 111      */
 112     private static final String uiClassID = "ViewportUI";
 113 
 114     /** Property used to indicate window blitting should not be done.
 115      */
 116     static final Object EnableWindowBlit = "EnableWindowBlit";
 117 
 118     /**
 119      * True when the viewport dimensions have been determined.
 120      * The default is false.
 121      */
 122     protected boolean isViewSizeSet = false;
 123 
 124     /**
 125      * The last <code>viewPosition</code> that we've painted, so we know how


1280     public void setExtentSize(Dimension newExtent) {
1281         Dimension oldExtent = getExtentSize();
1282         if (!newExtent.equals(oldExtent)) {
1283             setSize(newExtent);
1284             fireStateChanged();
1285         }
1286     }
1287 
1288     /**
1289      * A listener for the view.
1290      * <p>
1291      * <strong>Warning:</strong>
1292      * Serialized objects of this class will not be compatible with
1293      * future Swing releases. The current serialization support is
1294      * appropriate for short term storage or RMI between applications running
1295      * the same version of Swing.  As of 1.4, support for long term storage
1296      * of all JavaBeans&trade;
1297      * has been added to the <code>java.beans</code> package.
1298      * Please see {@link java.beans.XMLEncoder}.
1299      */
1300     @SuppressWarnings("serial") // Same-version serialization only
1301     protected class ViewListener extends ComponentAdapter implements Serializable
1302     {
1303         public void componentResized(ComponentEvent e) {
1304             fireStateChanged();
1305             revalidate();
1306         }
1307     }
1308 
1309     /**
1310      * Creates a listener for the view.
1311      * @return a <code>ViewListener</code>
1312      */
1313     protected ViewListener createViewListener() {
1314         return new ViewListener();
1315     }
1316 
1317 
1318     /**
1319      * Subclassers can override this to install a different
1320      * layout manager (or <code>null</code>) in the constructor.  Returns


1750         if (accessibleContext == null) {
1751             accessibleContext = new AccessibleJViewport();
1752         }
1753         return accessibleContext;
1754     }
1755 
1756     /**
1757      * This class implements accessibility support for the
1758      * <code>JViewport</code> class.  It provides an implementation of the
1759      * Java Accessibility API appropriate to viewport user-interface elements.
1760      * <p>
1761      * <strong>Warning:</strong>
1762      * Serialized objects of this class will not be compatible with
1763      * future Swing releases. The current serialization support is
1764      * appropriate for short term storage or RMI between applications running
1765      * the same version of Swing.  As of 1.4, support for long term storage
1766      * of all JavaBeans&trade;
1767      * has been added to the <code>java.beans</code> package.
1768      * Please see {@link java.beans.XMLEncoder}.
1769      */
1770     @SuppressWarnings("serial") // Same-version serialization only
1771     protected class AccessibleJViewport extends AccessibleJComponent {
1772         /**
1773          * Get the role of this object.
1774          *
1775          * @return an instance of AccessibleRole describing the role of
1776          * the object
1777          */
1778         public AccessibleRole getAccessibleRole() {
1779             return AccessibleRole.VIEWPORT;
1780         }
1781     } // inner class AccessibleJViewport
1782 }