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

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -20,11 +20,10 @@
  *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package javax.swing;
 
 import javax.swing.plaf.*;
 import javax.swing.border.*;
 import javax.swing.event.*;

@@ -38,10 +37,12 @@
 import java.awt.Point;
 
 import java.io.ObjectOutputStream;
 import java.io.IOException;
 
+import java.beans.JavaBean;
+import java.beans.BeanProperty;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.beans.Transient;
 
 /**

@@ -159,18 +160,15 @@
  * @see #setRowHeaderView
  * @see #setColumnHeaderView
  * @see #setCorner
  * @see #setViewportBorder
  *
- * @beaninfo
- *     attribute: isContainer true
- *     attribute: containerDelegate getViewport
- *   description: A specialized container that manages a viewport, optional scrollbars and headers
- *
  * @author Hans Muller
  * @since 1.2
  */
+@JavaBean(defaultProperty = "UI", description = "A specialized container that manages a viewport, optional scrollbars and headers")
+@SwingContainer(delegate = "getViewport")
 @SuppressWarnings("serial") // Same-version serialization only
 public class JScrollPane extends JComponent implements ScrollPaneConstants, Accessible
 {
     private Border viewportBorder;
 

@@ -358,16 +356,13 @@
      * Returns the look and feel (L&F) object that renders this component.
      *
      * @return the <code>ScrollPaneUI</code> object that renders this
      *                          component
      * @see #setUI
-     * @beaninfo
-     *        bound: true
-     *       hidden: true
-     *    attribute: visualUpdate true
-     *  description: The UI object that implements the Component's LookAndFeel.
      */
+    @BeanProperty(hidden = true, visualUpdate = true, description
+            = "The UI object that implements the Component's LookAndFeel.")
     public ScrollPaneUI getUI() {
         return (ScrollPaneUI)ui;
     }
 
 

@@ -401,14 +396,12 @@
      * render this component.
      *
      * @return the string "ScrollPaneUI"
      * @see JComponent#getUIClassID
      * @see UIDefaults#getUI
-     *
-     * @beaninfo
-     *    hidden: true
      */
+    @BeanProperty(bound = false, hidden = true)
     public String getUIClassID() {
         return uiClassID;
     }
 
 

@@ -425,13 +418,10 @@
      * @param layout the specified layout manager
      * @exception ClassCastException if layout is not a
      *                  <code>ScrollPaneLayout</code>
      * @see java.awt.Container#getLayout
      * @see java.awt.Container#setLayout
-     *
-     * @beaninfo
-     *    hidden: true
      */
     public void setLayout(LayoutManager layout) {
         if (layout instanceof ScrollPaneLayout) {
             super.setLayout(layout);
             ((ScrollPaneLayout)layout).syncWithScrollPane(this);

@@ -454,15 +444,13 @@
      * @return true
      * @see java.awt.Container#validate
      * @see JComponent#revalidate
      * @see JComponent#isValidateRoot
      * @see java.awt.Container#isValidateRoot
-     *
-     * @beaninfo
-     *    hidden: true
      */
     @Override
+    @BeanProperty(hidden = true)
     public boolean isValidateRoot() {
         return true;
     }
 
 

@@ -487,19 +475,16 @@
      *
      * @param policy one of the three values listed above
      * @exception IllegalArgumentException if <code>policy</code>
      *                          is not one of the legal values shown above
      * @see #getVerticalScrollBarPolicy
-     *
-     * @beaninfo
-     *   preferred: true
-     *       bound: true
-     * description: The scrollpane vertical scrollbar policy
-     *        enum: VERTICAL_SCROLLBAR_AS_NEEDED ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
-     *              VERTICAL_SCROLLBAR_NEVER ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER
-     *              VERTICAL_SCROLLBAR_ALWAYS ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
      */
+    @BeanProperty(preferred = true, enumerationValues = {
+            "ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED",
+            "ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER",
+            "ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS"}, description
+            = "The scrollpane vertical scrollbar policy")
     public void setVerticalScrollBarPolicy(int policy) {
         switch (policy) {
         case VERTICAL_SCROLLBAR_AS_NEEDED:
         case VERTICAL_SCROLLBAR_NEVER:
         case VERTICAL_SCROLLBAR_ALWAYS:

@@ -535,19 +520,16 @@
      *
      * @param policy one of the three values listed above
      * @exception IllegalArgumentException if <code>policy</code>
      *                          is not one of the legal values shown above
      * @see #getHorizontalScrollBarPolicy
-     *
-     * @beaninfo
-     *   preferred: true
-     *       bound: true
-     * description: The scrollpane scrollbar policy
-     *        enum: HORIZONTAL_SCROLLBAR_AS_NEEDED ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
-     *              HORIZONTAL_SCROLLBAR_NEVER ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
-     *              HORIZONTAL_SCROLLBAR_ALWAYS ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS
      */
+    @BeanProperty(preferred = true, enumerationValues = {
+            "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED",
+            "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER",
+            "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS"}, description
+            = "The scrollpane scrollbar policy")
     public void setHorizontalScrollBarPolicy(int policy) {
         switch (policy) {
         case HORIZONTAL_SCROLLBAR_AS_NEEDED:
         case HORIZONTAL_SCROLLBAR_NEVER:
         case HORIZONTAL_SCROLLBAR_ALWAYS:

@@ -585,16 +567,13 @@
      * and feel implementation.
      *
      * @param viewportBorder the border to be added
      * @see #getViewportBorder
      * @see #setViewport
-     *
-     * @beaninfo
-     *   preferred: true
-     *       bound: true
-     * description: The border around the viewport.
      */
+    @BeanProperty(preferred = true, description
+            = "The border around the viewport.")
     public void setViewportBorder(Border viewportBorder) {
         Border oldValue = this.viewportBorder;
         this.viewportBorder = viewportBorder;
         firePropertyChange("viewportBorder", oldValue, viewportBorder);
     }

@@ -603,10 +582,11 @@
     /**
      * Returns the bounds of the viewport's border.
      *
      * @return a <code>Rectangle</code> object specifying the viewport border
      */
+    @BeanProperty(bound = false)
     public Rectangle getViewportBorderBounds()
     {
         Rectangle borderR = new Rectangle(getSize());
 
         Insets insets = getInsets();

@@ -838,16 +818,13 @@
      * horizontal and vertical scrollbars by default.
      *
      * @param horizontalScrollBar the horizontal scrollbar to be added
      * @see #createHorizontalScrollBar
      * @see #getHorizontalScrollBar
-     *
-     * @beaninfo
-     *        expert: true
-     *         bound: true
-     *   description: The horizontal scrollbar.
      */
+    @BeanProperty(expert = true, description
+            = "The horizontal scrollbar.")
     public void setHorizontalScrollBar(JScrollBar horizontalScrollBar) {
         JScrollBar old = getHorizontalScrollBar();
         this.horizontalScrollBar = horizontalScrollBar;
         if (horizontalScrollBar != null) {
             add(horizontalScrollBar, HORIZONTAL_SCROLLBAR);

@@ -897,16 +874,13 @@
      * horizontal scrollbars by default.
      *
      * @param verticalScrollBar the new vertical scrollbar to be added
      * @see #createVerticalScrollBar
      * @see #getVerticalScrollBar
-     *
-     * @beaninfo
-     *        expert: true
-     *         bound: true
-     *   description: The vertical scrollbar.
      */
+    @BeanProperty(expert = true, description
+            = "The vertical scrollbar.")
     public void setVerticalScrollBar(JScrollBar verticalScrollBar) {
         JScrollBar old = getVerticalScrollBar();
         this.verticalScrollBar = verticalScrollBar;
         add(verticalScrollBar, VERTICAL_SCROLLBAR);
         firePropertyChange("verticalScrollBar", old, verticalScrollBar);

@@ -957,18 +931,13 @@
      *          <code>null</code>, the old viewport is still removed
      *          and the new viewport is set to <code>null</code>
      * @see #createViewport
      * @see #getViewport
      * @see #setViewportView
-     *
-     * @beaninfo
-     *       expert: true
-     *        bound: true
-     *    attribute: visualUpdate true
-     *  description: The viewport child for this scrollpane
-     *
      */
+    @BeanProperty(expert = true, visualUpdate = true, description
+            = "The viewport child for this scrollpane")
     public void setViewport(JViewport viewport) {
         JViewport old = getViewport();
         this.viewport = viewport;
         if (viewport != null) {
             add(viewport, VIEWPORT);

@@ -1036,16 +1005,13 @@
      * @param rowHeader the new row header to be used; if <code>null</code>
      *          the old row header is still removed and the new rowHeader
      *          is set to <code>null</code>
      * @see #getRowHeader
      * @see #setRowHeaderView
-     *
-     * @beaninfo
-     *        bound: true
-     *       expert: true
-     *  description: The row header child for this scrollpane
      */
+    @BeanProperty(expert = true, description
+            = "The row header child for this scrollpane")
     public void setRowHeader(JViewport rowHeader) {
         JViewport old = getRowHeader();
         this.rowHeader = rowHeader;
         if (rowHeader != null) {
             add(rowHeader, ROW_HEADER);

@@ -1103,16 +1069,13 @@
      * to add a column header component and its viewport to the scroll pane.
      *
      * @param columnHeader  a {@code JViewport} which is the new column header
      * @see #getColumnHeader
      * @see #setColumnHeaderView
-     *
-     * @beaninfo
-     *        bound: true
-     *  description: The column header child for this scrollpane
-     *    attribute: visualUpdate true
      */
+    @BeanProperty(visualUpdate = true, description
+            = "The column header child for this scrollpane")
     public void setColumnHeader(JViewport columnHeader) {
         JViewport old = getColumnHeader();
         this.columnHeader = columnHeader;
         if (columnHeader != null) {
             add(columnHeader, COLUMN_HEADER);

@@ -1301,14 +1264,13 @@
      * mouse wheel.  Wheel scrolling is enabled by default.
      *
      * @return true if mouse wheel scrolling is enabled, false otherwise
      * @see #setWheelScrollingEnabled
      * @since 1.4
-     * @beaninfo
-     *       bound: true
-     * description: Flag for enabling/disabling mouse wheel scrolling
      */
+    @BeanProperty(description
+            = "Flag for enabling/disabling mouse wheel scrolling")
     public boolean isWheelScrollingEnabled() {return wheelScrollState;}
 
     /**
      * Enables/disables scrolling in response to movement of the mouse wheel.
      * Wheel scrolling is enabled by default.

@@ -1318,14 +1280,13 @@
      *                      <code>false</code> otherwise.
      * @see #isWheelScrollingEnabled
      * @see java.awt.event.MouseWheelEvent
      * @see java.awt.event.MouseWheelListener
      * @since 1.4
-     * @beaninfo
-     *       bound: true
-     * description: Flag for enabling/disabling mouse wheel scrolling
      */
+    @BeanProperty(description
+            = "Flag for enabling/disabling mouse wheel scrolling")
     public void setWheelScrollingEnabled(boolean handleWheel) {
         boolean old = wheelScrollState;
         wheelScrollState = handleWheel;
         firePropertyChange("wheelScrollingEnabled", old, handleWheel);
     }

@@ -1422,10 +1383,11 @@
      * A new AccessibleJScrollPane instance is created if necessary.
      *
      * @return an AccessibleJScrollPane that serves as the
      *         AccessibleContext of this JScrollPane
      */
+    @BeanProperty(bound = false)
     public AccessibleContext getAccessibleContext() {
         if (accessibleContext == null) {
             accessibleContext = new AccessibleJScrollPane();
         }
         return accessibleContext;