< prev index next >

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

Print this page

        

*** 44,85 **** import java.beans.PropertyChangeListener; import java.beans.Transient; /** * Provides a scrollable view of a lightweight component. ! * A <code>JScrollPane</code> manages a viewport, optional * vertical and horizontal scroll bars, and optional row and * column heading viewports. ! * You can find task-oriented documentation of <code>JScrollPane</code> in * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/scrollpane.html">How to Use Scroll Panes</a>, * a section in <em>The Java Tutorial</em>. Note that ! * <code>JScrollPane</code> does not support heavyweight components. * * <TABLE STYLE="FLOAT:RIGHT" BORDER="0" SUMMARY="layout"> * <TR> * <TD ALIGN="CENTER"> * <P STYLE="TEXT-ALIGN:CENTER"><IMG SRC="doc-files/JScrollPane-1.gif" * alt="The following text describes this image." * WIDTH="256" HEIGHT="248" STYLE="FLOAT:BOTTOM; BORDER:0px"> * </TD> * </TR> * </TABLE> ! * The <code>JViewport</code> provides a window, * or &quot;viewport&quot; onto a data * source -- for example, a text file. That data source is the * &quot;scrollable client&quot; (aka data model) displayed by the ! * <code>JViewport</code> view. ! * A <code>JScrollPane</code> basically consists of <code>JScrollBar</code>s, ! * a <code>JViewport</code>, and the wiring between them, * as shown in the diagram at right. * <p> * In addition to the scroll bars and viewport, ! * a <code>JScrollPane</code> can have a * column header and a row header. Each of these is a ! * <code>JViewport</code> object that ! * you specify with <code>setRowHeaderView</code>, ! * and <code>setColumnHeaderView</code>. * The column header viewport automatically scrolls left and right, tracking * the left-right scrolling of the main viewport. * (It never scrolls vertically, however.) * The row header acts in a similar fashion. * <p> --- 44,85 ---- import java.beans.PropertyChangeListener; import java.beans.Transient; /** * Provides a scrollable view of a lightweight component. ! * A {@code JScrollPane} manages a viewport, optional * vertical and horizontal scroll bars, and optional row and * column heading viewports. ! * You can find task-oriented documentation of {@code JScrollPane} in * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/scrollpane.html">How to Use Scroll Panes</a>, * a section in <em>The Java Tutorial</em>. Note that ! * {@code JScrollPane} does not support heavyweight components. * * <TABLE STYLE="FLOAT:RIGHT" BORDER="0" SUMMARY="layout"> * <TR> * <TD ALIGN="CENTER"> * <P STYLE="TEXT-ALIGN:CENTER"><IMG SRC="doc-files/JScrollPane-1.gif" * alt="The following text describes this image." * WIDTH="256" HEIGHT="248" STYLE="FLOAT:BOTTOM; BORDER:0px"> * </TD> * </TR> * </TABLE> ! * The {@code JViewport} provides a window, * or &quot;viewport&quot; onto a data * source -- for example, a text file. That data source is the * &quot;scrollable client&quot; (aka data model) displayed by the ! * {@code JViewport} view. ! * A {@code JScrollPane} basically consists of {@code JScrollBar}s, ! * a {@code JViewport}, and the wiring between them, * as shown in the diagram at right. * <p> * In addition to the scroll bars and viewport, ! * a {@code JScrollPane} can have a * column header and a row header. Each of these is a ! * {@code JViewport} object that ! * you specify with {@code setRowHeaderView}, ! * and {@code setColumnHeaderView}. * The column header viewport automatically scrolls left and right, tracking * the left-right scrolling of the main viewport. * (It never scrolls vertically, however.) * The row header acts in a similar fashion. * <p>
*** 89,99 **** * These spaces can potentially exist in any number of the four corners. * In the previous diagram, the top right space is present and identified * by the label "corner component". * <p> * Any number of these empty spaces can be replaced by using the ! * <code>setCorner</code> method to add a component to a particular corner. * (Note: The same component cannot be added to multiple corners.) * This is useful if there's * some extra decoration or function you'd like to add to the scroll pane. * The size of each corner component is entirely determined by the size of the * headers and/or scroll bars that surround it. --- 89,99 ---- * These spaces can potentially exist in any number of the four corners. * In the previous diagram, the top right space is present and identified * by the label "corner component". * <p> * Any number of these empty spaces can be replaced by using the ! * {@code setCorner} method to add a component to a particular corner. * (Note: The same component cannot be added to multiple corners.) * This is useful if there's * some extra decoration or function you'd like to add to the scroll pane. * The size of each corner component is entirely determined by the size of the * headers and/or scroll bars that surround it.
*** 104,141 **** * vertical scrollbar is not present, perhaps because the view component hasn't * grown large enough to require it, then the corner component will not be * shown (since there is no empty space in that corner created by the meeting * of the header and vertical scroll bar). Forcing the scroll bar to always be * shown, using ! * <code>setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_ALWAYS)</code>, * will ensure that the space for the corner component always exists. * <p> * To add a border around the main viewport, ! * you can use <code>setViewportBorder</code>. * (Of course, you can also add a border around the whole scroll pane using ! * <code>setBorder</code>.) * <p> * A common operation to want to do is to set the background color that will * be used if the main viewport view is smaller than the viewport, or is * not opaque. This can be accomplished by setting the background color ! * of the viewport, via <code>scrollPane.getViewport().setBackground()</code>. * The reason for setting the color of the viewport and not the scrollpane ! * is that by default <code>JViewport</code> is opaque * which, among other things, means it will completely fill * in its background using its background color. Therefore when ! * <code>JScrollPane</code> draws its background the viewport will * usually draw over it. * <p> ! * By default <code>JScrollPane</code> uses <code>ScrollPaneLayout</code> ! * to handle the layout of its child Components. <code>ScrollPaneLayout</code> * determines the size to make the viewport view in one of two ways: * <ol> ! * <li>If the view implements <code>Scrollable</code> ! * a combination of <code>getPreferredScrollableViewportSize</code>, ! * <code>getScrollableTracksViewportWidth</code> and ! * <code>getScrollableTracksViewportHeight</code>is used, otherwise ! * <li><code>getPreferredSize</code> is used. * </ol> * <p> * <strong>Warning:</strong> Swing is not thread safe. For more * information see <a * href="package-summary.html#threading">Swing's Threading --- 104,141 ---- * vertical scrollbar is not present, perhaps because the view component hasn't * grown large enough to require it, then the corner component will not be * shown (since there is no empty space in that corner created by the meeting * of the header and vertical scroll bar). Forcing the scroll bar to always be * shown, using ! * {@code setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_ALWAYS)}, * will ensure that the space for the corner component always exists. * <p> * To add a border around the main viewport, ! * you can use {@code setViewportBorder}. * (Of course, you can also add a border around the whole scroll pane using ! * {@code setBorder}.) * <p> * A common operation to want to do is to set the background color that will * be used if the main viewport view is smaller than the viewport, or is * not opaque. This can be accomplished by setting the background color ! * of the viewport, via {@code scrollPane.getViewport().setBackground()}. * The reason for setting the color of the viewport and not the scrollpane ! * is that by default {@code JViewport} is opaque * which, among other things, means it will completely fill * in its background using its background color. Therefore when ! * {@code JScrollPane} draws its background the viewport will * usually draw over it. * <p> ! * By default {@code JScrollPane} uses {@code ScrollPaneLayout} ! * to handle the layout of its child Components. {@code ScrollPaneLayout} * determines the size to make the viewport view in one of two ways: * <ol> ! * <li>If the view implements {@code Scrollable} ! * a combination of {@code getPreferredScrollableViewportSize}, ! * {@code getScrollableTracksViewportWidth} and ! * {@code getScrollableTracksViewportHeight} is used, otherwise ! * <li>{@code getPreferredSize} is used. * </ol> * <p> * <strong>Warning:</strong> Swing is not thread safe. For more * information see <a * href="package-summary.html#threading">Swing's Threading
*** 145,155 **** * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @see JScrollBar * @see JViewport * @see ScrollPaneLayout --- 145,155 ---- * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. * * @see JScrollBar * @see JViewport * @see ScrollPaneLayout
*** 181,286 **** private static final String uiClassID = "ScrollPaneUI"; /** * The display policy for the vertical scrollbar. * The default is ! * <code>ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED</code>. * @see #setVerticalScrollBarPolicy */ protected int verticalScrollBarPolicy = VERTICAL_SCROLLBAR_AS_NEEDED; /** * The display policy for the horizontal scrollbar. * The default is ! * <code>ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED</code>. * @see #setHorizontalScrollBarPolicy */ protected int horizontalScrollBarPolicy = HORIZONTAL_SCROLLBAR_AS_NEEDED; /** * The scrollpane's viewport child. Default is an empty ! * <code>JViewport</code>. * @see #setViewport */ protected JViewport viewport; /** * The scrollpane's vertical scrollbar child. ! * Default is a <code>JScrollBar</code>. * @see #setVerticalScrollBar */ protected JScrollBar verticalScrollBar; /** * The scrollpane's horizontal scrollbar child. ! * Default is a <code>JScrollBar</code>. * @see #setHorizontalScrollBar */ protected JScrollBar horizontalScrollBar; /** ! * The row header child. Default is <code>null</code>. * @see #setRowHeader */ protected JViewport rowHeader; /** ! * The column header child. Default is <code>null</code>. * @see #setColumnHeader */ protected JViewport columnHeader; /** * The component to display in the lower left corner. ! * Default is <code>null</code>. * @see #setCorner */ protected Component lowerLeft; /** * The component to display in the lower right corner. ! * Default is <code>null</code>. * @see #setCorner */ protected Component lowerRight; /** * The component to display in the upper left corner. ! * Default is <code>null</code>. * @see #setCorner */ protected Component upperLeft; /** * The component to display in the upper right corner. ! * Default is <code>null</code>. * @see #setCorner */ protected Component upperRight; /* * State flag for mouse wheel scrolling */ private boolean wheelScrollState = true; /** ! * Creates a <code>JScrollPane</code> that displays the view * component in a viewport * whose view position can be controlled with a pair of scrollbars. * The scrollbar policies specify when the scrollbars are displayed, ! * For example, if <code>vsbPolicy</code> is ! * <code>VERTICAL_SCROLLBAR_AS_NEEDED</code> * then the vertical scrollbar only appears if the view doesn't fit * vertically. The available policy settings are listed at * {@link #setVerticalScrollBarPolicy} and * {@link #setHorizontalScrollBarPolicy}. * --- 181,286 ---- private static final String uiClassID = "ScrollPaneUI"; /** * The display policy for the vertical scrollbar. * The default is ! * {@code ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED}. * @see #setVerticalScrollBarPolicy */ protected int verticalScrollBarPolicy = VERTICAL_SCROLLBAR_AS_NEEDED; /** * The display policy for the horizontal scrollbar. * The default is ! * {@code ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED}. * @see #setHorizontalScrollBarPolicy */ protected int horizontalScrollBarPolicy = HORIZONTAL_SCROLLBAR_AS_NEEDED; /** * The scrollpane's viewport child. Default is an empty ! * {@code JViewport}. * @see #setViewport */ protected JViewport viewport; /** * The scrollpane's vertical scrollbar child. ! * Default is a {@code JScrollBar}. * @see #setVerticalScrollBar */ protected JScrollBar verticalScrollBar; /** * The scrollpane's horizontal scrollbar child. ! * Default is a {@code JScrollBar}. * @see #setHorizontalScrollBar */ protected JScrollBar horizontalScrollBar; /** ! * The row header child. Default is {@code null}. * @see #setRowHeader */ protected JViewport rowHeader; /** ! * The column header child. Default is {@code null}. * @see #setColumnHeader */ protected JViewport columnHeader; /** * The component to display in the lower left corner. ! * Default is {@code null}. * @see #setCorner */ protected Component lowerLeft; /** * The component to display in the lower right corner. ! * Default is {@code null}. * @see #setCorner */ protected Component lowerRight; /** * The component to display in the upper left corner. ! * Default is {@code null}. * @see #setCorner */ protected Component upperLeft; /** * The component to display in the upper right corner. ! * Default is {@code null}. * @see #setCorner */ protected Component upperRight; /* * State flag for mouse wheel scrolling */ private boolean wheelScrollState = true; /** ! * Creates a {@code JScrollPane} that displays the view * component in a viewport * whose view position can be controlled with a pair of scrollbars. * The scrollbar policies specify when the scrollbars are displayed, ! * For example, if {@code vsbPolicy} is ! * {@code VERTICAL_SCROLLBAR_AS_NEEDED} * then the vertical scrollbar only appears if the view doesn't fit * vertically. The available policy settings are listed at * {@link #setVerticalScrollBarPolicy} and * {@link #setHorizontalScrollBarPolicy}. *
*** 311,321 **** } } /** ! * Creates a <code>JScrollPane</code> that displays the * contents of the specified * component, where both horizontal and vertical scrollbars appear * whenever the component's contents are larger than the view. * * @see #setViewportView --- 311,321 ---- } } /** ! * Creates a {@code JScrollPane} that displays the * contents of the specified * component, where both horizontal and vertical scrollbars appear * whenever the component's contents are larger than the view. * * @see #setViewportView
*** 325,335 **** this(view, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); } /** ! * Creates an empty (no viewport view) <code>JScrollPane</code> * with specified * scrollbar policies. The available policy settings are listed at * {@link #setVerticalScrollBarPolicy} and * {@link #setHorizontalScrollBarPolicy}. * --- 325,335 ---- this(view, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); } /** ! * Creates an empty (no viewport view) {@code JScrollPane} * with specified * scrollbar policies. The available policy settings are listed at * {@link #setVerticalScrollBarPolicy} and * {@link #setHorizontalScrollBarPolicy}. *
*** 344,365 **** this(null, vsbPolicy, hsbPolicy); } /** ! * Creates an empty (no viewport view) <code>JScrollPane</code> * where both horizontal and vertical scrollbars appear when needed. */ public JScrollPane() { this(null, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); } /** * Returns the look and feel (L&amp;F) object that renders this component. * ! * @return the <code>ScrollPaneUI</code> object that renders this * component * @see #setUI * @beaninfo * bound: true * hidden: true --- 344,365 ---- this(null, vsbPolicy, hsbPolicy); } /** ! * Creates an empty (no viewport view) {@code JScrollPane} * where both horizontal and vertical scrollbars appear when needed. */ public JScrollPane() { this(null, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); } /** * Returns the look and feel (L&amp;F) object that renders this component. * ! * @return the {@code ScrollPaneUI} object that renders this * component * @see #setUI * @beaninfo * bound: true * hidden: true
*** 370,392 **** return (ScrollPaneUI)ui; } /** ! * Sets the <code>ScrollPaneUI</code> object that provides the * look and feel (L&amp;F) for this component. * ! * @param ui the <code>ScrollPaneUI</code> L&amp;F object * @see #getUI */ public void setUI(ScrollPaneUI ui) { super.setUI(ui); } /** ! * Replaces the current <code>ScrollPaneUI</code> object with a version * from the current default look and feel. * To be called when the default look and feel changes. * * @see JComponent#updateUI * @see UIManager#getUI --- 370,392 ---- return (ScrollPaneUI)ui; } /** ! * Sets the {@code ScrollPaneUI} object that provides the * look and feel (L&amp;F) for this component. * ! * @param ui the {@code ScrollPaneUI} L&amp;F object * @see #getUI */ public void setUI(ScrollPaneUI ui) { super.setUI(ui); } /** ! * Replaces the current {@code ScrollPaneUI} object with a version * from the current default look and feel. * To be called when the default look and feel changes. * * @see JComponent#updateUI * @see UIManager#getUI
*** 412,432 **** } /** ! * Sets the layout manager for this <code>JScrollPane</code>. ! * This method overrides <code>setLayout</code> in ! * <code>java.awt.Container</code> to ensure that only ! * <code>LayoutManager</code>s which ! * are subclasses of <code>ScrollPaneLayout</code> can be used in a ! * <code>JScrollPane</code>. If <code>layout</code> is non-null, this ! * will invoke <code>syncWithScrollPane</code> on it. * * @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 --- 412,432 ---- } /** ! * Sets the layout manager for this {@code JScrollPane}. ! * This method overrides {@code setLayout} in ! * {@code java.awt.Container} to ensure that only ! * {@code LayoutManager}s which ! * are subclasses of {@code ScrollPaneLayout} can be used in a ! * {@code JScrollPane}. If {@code layout} is non-null, this ! * will invoke {@code syncWithScrollPane} on it. * * @param layout the specified layout manager * @exception ClassCastException if layout is not a ! * {@code ScrollPaneLayout} * @see java.awt.Container#getLayout * @see java.awt.Container#setLayout * * @beaninfo * hidden: true
*** 444,456 **** throw new ClassCastException(s); } } /** ! * Overridden to return true so that any calls to <code>revalidate</code> ! * on any descendants of this <code>JScrollPane</code> will cause the ! * entire tree beginning with this <code>JScrollPane</code> to be * validated. * * @return true * @see java.awt.Container#validate * @see JComponent#revalidate --- 444,456 ---- throw new ClassCastException(s); } } /** ! * Overridden to return true so that any calls to {@code revalidate} ! * on any descendants of this {@code JScrollPane} will cause the ! * entire tree beginning with this {@code JScrollPane} to be * validated. * * @return true * @see java.awt.Container#validate * @see JComponent#revalidate
*** 466,476 **** } /** * Returns the vertical scroll bar policy value. ! * @return the <code>verticalScrollBarPolicy</code> property * @see #setVerticalScrollBarPolicy */ public int getVerticalScrollBarPolicy() { return verticalScrollBarPolicy; } --- 466,476 ---- } /** * Returns the vertical scroll bar policy value. ! * @return the {@code verticalScrollBarPolicy} property * @see #setVerticalScrollBarPolicy */ public int getVerticalScrollBarPolicy() { return verticalScrollBarPolicy; }
*** 478,494 **** /** * Determines when the vertical scrollbar appears in the scrollpane. * Legal values are: * <ul> ! * <li><code>ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED</code> ! * <li><code>ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER</code> ! * <li><code>ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS</code> * </ul> * * @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 --- 478,494 ---- /** * Determines when the vertical scrollbar appears in the scrollpane. * Legal values are: * <ul> ! * <li>{@code ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED} ! * <li>{@code ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER} ! * <li>{@code ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS} * </ul> * * @param policy one of the three values listed above ! * @exception IllegalArgumentException if {@code policy} * is not one of the legal values shown above * @see #getVerticalScrollBarPolicy * * @beaninfo * preferred: true
*** 515,542 **** } /** * Returns the horizontal scroll bar policy value. ! * @return the <code>horizontalScrollBarPolicy</code> property * @see #setHorizontalScrollBarPolicy */ public int getHorizontalScrollBarPolicy() { return horizontalScrollBarPolicy; } /** * Determines when the horizontal scrollbar appears in the scrollpane. * The options are:<ul> ! * <li><code>ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED</code> ! * <li><code>ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER</code> ! * <li><code>ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS</code> * </ul> * * @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 --- 515,542 ---- } /** * Returns the horizontal scroll bar policy value. ! * @return the {@code horizontalScrollBarPolicy} property * @see #setHorizontalScrollBarPolicy */ public int getHorizontalScrollBarPolicy() { return horizontalScrollBarPolicy; } /** * Determines when the horizontal scrollbar appears in the scrollpane. * The options are:<ul> ! * <li>{@code ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED} ! * <li>{@code ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER} ! * <li>{@code ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS} * </ul> * * @param policy one of the three values listed above ! * @exception IllegalArgumentException if {@code policy} * is not one of the legal values shown above * @see #getHorizontalScrollBarPolicy * * @beaninfo * preferred: true
*** 562,587 **** repaint(); } /** ! * Returns the <code>Border</code> object that surrounds the viewport. * ! * @return the <code>viewportBorder</code> property * @see #setViewportBorder */ public Border getViewportBorder() { return viewportBorder; } /** * Adds a border around the viewport. Note that the border isn't ! * set on the viewport directly, <code>JViewport</code> doesn't support ! * the <code>JComponent</code> border property. ! * Similarly setting the <code>JScrollPane</code>s ! * viewport doesn't affect the <code>viewportBorder</code> property. * <p> * The default value of this property is computed by the look * and feel implementation. * * @param viewportBorder the border to be added --- 562,587 ---- repaint(); } /** ! * Returns the {@code Border} object that surrounds the viewport. * ! * @return the {@code viewportBorder} property * @see #setViewportBorder */ public Border getViewportBorder() { return viewportBorder; } /** * Adds a border around the viewport. Note that the border isn't ! * set on the viewport directly, {@code JViewport} doesn't support ! * the {@code JComponent} border property. ! * Similarly setting the {@code JScrollPane}s ! * viewport doesn't affect the {@code viewportBorder} property. * <p> * The default value of this property is computed by the look * and feel implementation. * * @param viewportBorder the border to be added
*** 601,611 **** /** * Returns the bounds of the viewport's border. * ! * @return a <code>Rectangle</code> object specifying the viewport border */ public Rectangle getViewportBorderBounds() { Rectangle borderR = new Rectangle(getSize()); --- 601,611 ---- /** * Returns the bounds of the viewport's border. * ! * @return a {@code Rectangle} object specifying the viewport border */ public Rectangle getViewportBorderBounds() { Rectangle borderR = new Rectangle(getSize());
*** 664,688 **** return borderR; } /** ! * By default <code>JScrollPane</code> creates scrollbars * that are instances ! * of this class. <code>Scrollbar</code> overrides the ! * <code>getUnitIncrement</code> and <code>getBlockIncrement</code> ! * methods so that, if the viewport's view is a <code>Scrollable</code>, * the view is asked to compute these values. Unless * the unit/block increment have been explicitly set. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @see Scrollable * @see JScrollPane#createVerticalScrollBar * @see JScrollPane#createHorizontalScrollBar --- 664,688 ---- return borderR; } /** ! * By default {@code JScrollPane} creates scrollbars * that are instances ! * of this class. {@code Scrollbar} overrides the ! * {@code getUnitIncrement} and {@code getBlockIncrement} ! * methods so that, if the viewport's view is a {@code Scrollable}, * the view is asked to compute these values. Unless * the unit/block increment have been explicitly set. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. * * @see Scrollable * @see JScrollPane#createVerticalScrollBar * @see JScrollPane#createHorizontalScrollBar
*** 691,718 **** protected class ScrollBar extends JScrollBar implements UIResource { /** * Set to true when the unit increment has been explicitly set. * If this is false the viewport's view is obtained and if it ! * is an instance of <code>Scrollable</code> the unit increment * from it is used. */ private boolean unitIncrementSet; /** * Set to true when the block increment has been explicitly set. * If this is false the viewport's view is obtained and if it ! * is an instance of <code>Scrollable</code> the block increment * from it is used. */ private boolean blockIncrementSet; /** * Creates a scrollbar with the specified orientation. * The options are: * <ul> ! * <li><code>ScrollPaneConstants.VERTICAL</code> ! * <li><code>ScrollPaneConstants.HORIZONTAL</code> * </ul> * * @param orientation an integer specifying one of the legal * orientation values shown above * @since 1.4 --- 691,718 ---- protected class ScrollBar extends JScrollBar implements UIResource { /** * Set to true when the unit increment has been explicitly set. * If this is false the viewport's view is obtained and if it ! * is an instance of {@code Scrollable} the unit increment * from it is used. */ private boolean unitIncrementSet; /** * Set to true when the block increment has been explicitly set. * If this is false the viewport's view is obtained and if it ! * is an instance of {@code Scrollable} the block increment * from it is used. */ private boolean blockIncrementSet; /** * Creates a scrollbar with the specified orientation. * The options are: * <ul> ! * <li>{@code ScrollPaneConstants.VERTICAL} ! * <li>{@code ScrollPaneConstants.HORIZONTAL} * </ul> * * @param orientation an integer specifying one of the legal * orientation values shown above * @since 1.4
*** 723,733 **** Boolean.TRUE); } /** * Messages super to set the value, and resets the ! * <code>unitIncrementSet</code> instance variable to true. * * @param unitIncrement the new unit increment value, in pixels */ public void setUnitIncrement(int unitIncrement) { unitIncrementSet = true; --- 723,733 ---- Boolean.TRUE); } /** * Messages super to set the value, and resets the ! * {@code unitIncrementSet} instance variable to true. * * @param unitIncrement the new unit increment value, in pixels */ public void setUnitIncrement(int unitIncrement) { unitIncrementSet = true;
*** 735,746 **** super.setUnitIncrement(unitIncrement); } /** * Computes the unit increment for scrolling if the viewport's ! * view is a <code>Scrollable</code> object. ! * Otherwise return <code>super.getUnitIncrement</code>. * * @param direction less than zero to scroll up/left, * greater than zero for down/right * @return an integer, in pixels, containing the unit increment * @see Scrollable#getScrollableUnitIncrement --- 735,746 ---- super.setUnitIncrement(unitIncrement); } /** * Computes the unit increment for scrolling if the viewport's ! * view is a {@code Scrollable} object. ! * Otherwise return {@code super.getUnitIncrement}. * * @param direction less than zero to scroll up/left, * greater than zero for down/right * @return an integer, in pixels, containing the unit increment * @see Scrollable#getScrollableUnitIncrement
*** 758,768 **** } } /** * Messages super to set the value, and resets the ! * <code>blockIncrementSet</code> instance variable to true. * * @param blockIncrement the new block increment value, in pixels */ public void setBlockIncrement(int blockIncrement) { blockIncrementSet = true; --- 758,768 ---- } } /** * Messages super to set the value, and resets the ! * {@code blockIncrementSet} instance variable to true. * * @param blockIncrement the new block increment value, in pixels */ public void setBlockIncrement(int blockIncrement) { blockIncrementSet = true;
*** 770,783 **** super.setBlockIncrement(blockIncrement); } /** * Computes the block increment for scrolling if the viewport's ! * view is a <code>Scrollable</code> object. Otherwise ! * the <code>blockIncrement</code> equals the viewport's width * or height. If there's no viewport return ! * <code>super.getBlockIncrement</code>. * * @param direction less than zero to scroll up/left, * greater than zero for down/right * @return an integer, in pixels, containing the block increment * @see Scrollable#getScrollableBlockIncrement --- 770,783 ---- super.setBlockIncrement(blockIncrement); } /** * Computes the block increment for scrolling if the viewport's ! * view is a {@code Scrollable} object. Otherwise ! * the {@code blockIncrement} equals the viewport's width * or height. If there's no viewport return ! * {@code super.getBlockIncrement}. * * @param direction less than zero to scroll up/left, * greater than zero for down/right * @return an integer, in pixels, containing the block increment * @see Scrollable#getScrollableBlockIncrement
*** 802,818 **** } /** ! * Returns a <code>JScrollPane.ScrollBar</code> by default. ! * Subclasses may override this method to force <code>ScrollPaneUI</code> ! * implementations to use a <code>JScrollBar</code> subclass. ! * Used by <code>ScrollPaneUI</code> implementations to * create the horizontal scrollbar. * ! * @return a <code>JScrollBar</code> with a horizontal orientation * @see JScrollBar */ public JScrollBar createHorizontalScrollBar() { return new ScrollBar(JScrollBar.HORIZONTAL); } --- 802,818 ---- } /** ! * Returns a {@code JScrollPane.ScrollBar} by default. ! * Subclasses may override this method to force {@code ScrollPaneUI} ! * implementations to use a {@code JScrollBar} subclass. ! * Used by {@code ScrollPaneUI} implementations to * create the horizontal scrollbar. * ! * @return a {@code JScrollBar} with a horizontal orientation * @see JScrollBar */ public JScrollBar createHorizontalScrollBar() { return new ScrollBar(JScrollBar.HORIZONTAL); }
*** 820,830 **** /** * Returns the horizontal scroll bar that controls the viewport's * horizontal view position. * ! * @return the <code>horizontalScrollBar</code> property * @see #setHorizontalScrollBar */ @Transient public JScrollBar getHorizontalScrollBar() { return horizontalScrollBar; --- 820,830 ---- /** * Returns the horizontal scroll bar that controls the viewport's * horizontal view position. * ! * @return the {@code horizontalScrollBar} property * @see #setHorizontalScrollBar */ @Transient public JScrollBar getHorizontalScrollBar() { return horizontalScrollBar;
*** 832,842 **** /** * Adds the scrollbar that controls the viewport's horizontal view * position to the scrollpane. ! * This is usually unnecessary, as <code>JScrollPane</code> creates * horizontal and vertical scrollbars by default. * * @param horizontalScrollBar the horizontal scrollbar to be added * @see #createHorizontalScrollBar * @see #getHorizontalScrollBar --- 832,842 ---- /** * Adds the scrollbar that controls the viewport's horizontal view * position to the scrollpane. ! * This is usually unnecessary, as {@code JScrollPane} creates * horizontal and vertical scrollbars by default. * * @param horizontalScrollBar the horizontal scrollbar to be added * @see #createHorizontalScrollBar * @see #getHorizontalScrollBar
*** 861,877 **** repaint(); } /** ! * Returns a <code>JScrollPane.ScrollBar</code> by default. Subclasses ! * may override this method to force <code>ScrollPaneUI</code> ! * implementations to use a <code>JScrollBar</code> subclass. ! * Used by <code>ScrollPaneUI</code> implementations to create the * vertical scrollbar. * ! * @return a <code>JScrollBar</code> with a vertical orientation * @see JScrollBar */ public JScrollBar createVerticalScrollBar() { return new ScrollBar(JScrollBar.VERTICAL); } --- 861,877 ---- repaint(); } /** ! * Returns a {@code JScrollPane.ScrollBar} by default. Subclasses ! * may override this method to force {@code ScrollPaneUI} ! * implementations to use a {@code JScrollBar} subclass. ! * Used by {@code ScrollPaneUI} implementations to create the * vertical scrollbar. * ! * @return a {@code JScrollBar} with a vertical orientation * @see JScrollBar */ public JScrollBar createVerticalScrollBar() { return new ScrollBar(JScrollBar.VERTICAL); }
*** 879,889 **** /** * Returns the vertical scroll bar that controls the viewports * vertical view position. * ! * @return the <code>verticalScrollBar</code> property * @see #setVerticalScrollBar */ @Transient public JScrollBar getVerticalScrollBar() { return verticalScrollBar; --- 879,889 ---- /** * Returns the vertical scroll bar that controls the viewports * vertical view position. * ! * @return the {@code verticalScrollBar} property * @see #setVerticalScrollBar */ @Transient public JScrollBar getVerticalScrollBar() { return verticalScrollBar;
*** 891,901 **** /** * Adds the scrollbar that controls the viewports vertical view position * to the scrollpane. This is usually unnecessary, ! * as <code>JScrollPane</code> creates vertical and * horizontal scrollbars by default. * * @param verticalScrollBar the new vertical scrollbar to be added * @see #createVerticalScrollBar * @see #getVerticalScrollBar --- 891,901 ---- /** * Adds the scrollbar that controls the viewports vertical view position * to the scrollpane. This is usually unnecessary, ! * as {@code JScrollPane} creates vertical and * horizontal scrollbars by default. * * @param verticalScrollBar the new vertical scrollbar to be added * @see #createVerticalScrollBar * @see #getVerticalScrollBar
*** 915,943 **** repaint(); } /** ! * Returns a new <code>JViewport</code> by default. * Used to create the ! * viewport (as needed) in <code>setViewportView</code>, ! * <code>setRowHeaderView</code>, and <code>setColumnHeaderView</code>. * Subclasses may override this method to return a subclass of ! * <code>JViewport</code>. * ! * @return a new <code>JViewport</code> */ protected JViewport createViewport() { return new JViewport(); } /** ! * Returns the current <code>JViewport</code>. * * @see #setViewport ! * @return the <code>viewport</code> property */ public JViewport getViewport() { return viewport; } --- 915,943 ---- repaint(); } /** ! * Returns a new {@code JViewport} by default. * Used to create the ! * viewport (as needed) in {@code setViewportView}, ! * {@code setRowHeaderView}, and {@code setColumnHeaderView}. * Subclasses may override this method to return a subclass of ! * {@code JViewport}. * ! * @return a new {@code JViewport} */ protected JViewport createViewport() { return new JViewport(); } /** ! * Returns the current {@code JViewport}. * * @see #setViewport ! * @return the {@code viewport} property */ public JViewport getViewport() { return viewport; }
*** 948,963 **** * syncs up the row and column headers (if there are any) with the * new viewport; and finally syncs the scrollbars and * headers with the new viewport. * <p> * Most applications will find it more convenient to use ! * <code>setViewportView</code> * to add a viewport and a view to the scrollpane. * * @param viewport the new viewport to be used; if viewport is ! * <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 --- 948,963 ---- * syncs up the row and column headers (if there are any) with the * new viewport; and finally syncs the scrollbars and * headers with the new viewport. * <p> * Most applications will find it more convenient to use ! * {@code setViewportView} * to add a viewport and a view to the scrollpane. * * @param viewport the new viewport to be used; if viewport is ! * {@code null}, the old viewport is still removed ! * and the new viewport is set to {@code null} * @see #createViewport * @see #getViewport * @see #setViewportView * * @beaninfo
*** 987,997 **** } /** * Creates a viewport if necessary and then sets its view. Applications ! * that don't provide the view directly to the <code>JScrollPane</code> * constructor * should use this method to specify the scrollable child that's going * to be displayed in the scrollpane. For example: * <pre> * JScrollPane scrollpane = new JScrollPane(); --- 987,997 ---- } /** * Creates a viewport if necessary and then sets its view. Applications ! * that don't provide the view directly to the {@code JScrollPane} * constructor * should use this method to specify the scrollable child that's going * to be displayed in the scrollpane. For example: * <pre> * JScrollPane scrollpane = new JScrollPane();
*** 1012,1043 **** /** * Returns the row header. ! * @return the <code>rowHeader</code> property * @see #setRowHeader */ @Transient public JViewport getRowHeader() { return rowHeader; } /** * Removes the old rowHeader, if it exists; if the new rowHeader ! * isn't <code>null</code>, syncs the y coordinate of its * viewPosition with * the viewport (if there is one) and then adds it to the scroll pane. * <p> * Most applications will find it more convenient to use ! * <code>setRowHeaderView</code> * to add a row header component and its viewport to the scroll pane. * ! * @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 --- 1012,1043 ---- /** * Returns the row header. ! * @return the {@code rowHeader} property * @see #setRowHeader */ @Transient public JViewport getRowHeader() { return rowHeader; } /** * Removes the old rowHeader, if it exists; if the new rowHeader ! * isn't {@code null}, syncs the y coordinate of its * viewPosition with * the viewport (if there is one) and then adds it to the scroll pane. * <p> * Most applications will find it more convenient to use ! * {@code setRowHeaderView} * to add a row header component and its viewport to the scroll pane. * ! * @param rowHeader the new row header to be used; if {@code null} * the old row header is still removed and the new rowHeader ! * is set to {@code null} * @see #getRowHeader * @see #setRowHeaderView * * @beaninfo * bound: true
*** 1082,1107 **** /** * Returns the column header. ! * @return the <code>columnHeader</code> property * @see #setColumnHeader */ @Transient public JViewport getColumnHeader() { return columnHeader; } /** * Removes the old columnHeader, if it exists; if the new columnHeader ! * isn't <code>null</code>, syncs the x coordinate of its viewPosition * with the viewport (if there is one) and then adds it to the scroll pane. * <p> * Most applications will find it more convenient to use ! * <code>setColumnHeaderView</code> * 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 --- 1082,1107 ---- /** * Returns the column header. ! * @return the {@code columnHeader} property * @see #setColumnHeader */ @Transient public JViewport getColumnHeader() { return columnHeader; } /** * Removes the old columnHeader, if it exists; if the new columnHeader ! * isn't {@code null}, syncs the x coordinate of its viewPosition * with the viewport (if there is one) and then adds it to the scroll pane. * <p> * Most applications will find it more convenient to use ! * {@code setColumnHeaderView} * 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
*** 1151,1161 **** } /** * Returns the component at the specified corner. The ! * <code>key</code> value specifying the corner is one of: * <ul> * <li>ScrollPaneConstants.LOWER_LEFT_CORNER * <li>ScrollPaneConstants.LOWER_RIGHT_CORNER * <li>ScrollPaneConstants.UPPER_LEFT_CORNER * <li>ScrollPaneConstants.UPPER_RIGHT_CORNER --- 1151,1161 ---- } /** * Returns the component at the specified corner. The ! * {@code key} value specifying the corner is one of: * <ul> * <li>ScrollPaneConstants.LOWER_LEFT_CORNER * <li>ScrollPaneConstants.LOWER_RIGHT_CORNER * <li>ScrollPaneConstants.UPPER_LEFT_CORNER * <li>ScrollPaneConstants.UPPER_RIGHT_CORNER
*** 1164,1175 **** * <li>ScrollPaneConstants.UPPER_LEADING_CORNER * <li>ScrollPaneConstants.UPPER_TRAILING_CORNER * </ul> * * @param key one of the values as shown above ! * @return the corner component (which may be <code>null</code>) ! * identified by the given key, or <code>null</code> * if the key is invalid * @see #setCorner */ public Component getCorner(String key) { boolean isLeftToRight = getComponentOrientation().isLeftToRight(); --- 1164,1175 ---- * <li>ScrollPaneConstants.UPPER_LEADING_CORNER * <li>ScrollPaneConstants.UPPER_TRAILING_CORNER * </ul> * * @param key one of the values as shown above ! * @return the corner component (which may be {@code null}) ! * identified by the given key, or {@code null} * if the key is invalid * @see #setCorner */ public Component getCorner(String key) { boolean isLeftToRight = getComponentOrientation().isLeftToRight();
*** 1217,1227 **** * <li>ScrollPaneConstants.UPPER_LEADING_CORNER * <li>ScrollPaneConstants.UPPER_TRAILING_CORNER * </ul> * <p> * Although "corner" doesn't match any beans property ! * signature, <code>PropertyChange</code> events are generated with the * property name set to the corner key. * * @param key identifies which corner the component will appear in * @param corner one of the following components: * <ul> --- 1217,1227 ---- * <li>ScrollPaneConstants.UPPER_LEADING_CORNER * <li>ScrollPaneConstants.UPPER_TRAILING_CORNER * </ul> * <p> * Although "corner" doesn't match any beans property ! * signature, {@code PropertyChange} events are generated with the * property name set to the corner key. * * @param key identifies which corner the component will appear in * @param corner one of the following components: * <ul>
*** 1276,1286 **** } /** * Sets the orientation for the vertical and horizontal * scrollbars as determined by the ! * <code>ComponentOrientation</code> argument. * * @param co one of the following values: * <ul> * <li>java.awt.ComponentOrientation.LEFT_TO_RIGHT * <li>java.awt.ComponentOrientation.RIGHT_TO_LEFT --- 1276,1286 ---- } /** * Sets the orientation for the vertical and horizontal * scrollbars as determined by the ! * {@code ComponentOrientation} argument. * * @param co one of the following values: * <ul> * <li>java.awt.ComponentOrientation.LEFT_TO_RIGHT * <li>java.awt.ComponentOrientation.RIGHT_TO_LEFT
*** 1311,1323 **** /** * Enables/disables scrolling in response to movement of the mouse wheel. * Wheel scrolling is enabled by default. * ! * @param handleWheel <code>true</code> if scrolling should be done * automatically for a MouseWheelEvent, ! * <code>false</code> otherwise. * @see #isWheelScrollingEnabled * @see java.awt.event.MouseWheelEvent * @see java.awt.event.MouseWheelListener * @since 1.4 * @beaninfo --- 1311,1323 ---- /** * Enables/disables scrolling in response to movement of the mouse wheel. * Wheel scrolling is enabled by default. * ! * @param handleWheel {@code true} if scrolling should be done * automatically for a MouseWheelEvent, ! * {@code false} otherwise. * @see #isWheelScrollingEnabled * @see java.awt.event.MouseWheelEvent * @see java.awt.event.MouseWheelListener * @since 1.4 * @beaninfo
*** 1329,1340 **** wheelScrollState = handleWheel; firePropertyChange("wheelScrollingEnabled", old, handleWheel); } /** ! * See <code>readObject</code> and <code>writeObject</code> in ! * <code>JComponent</code> for more * information about serialization in Swing. */ private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); if (getUIClassID().equals(uiClassID)) { --- 1329,1340 ---- wheelScrollState = handleWheel; firePropertyChange("wheelScrollingEnabled", old, handleWheel); } /** ! * See {@code readObject} and {@code writeObject} in ! * {@code JComponent} for more * information about serialization in Swing. */ private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); if (getUIClassID().equals(uiClassID)) {
*** 1346,1363 **** } } /** ! * Returns a string representation of this <code>JScrollPane</code>. * This method * is intended to be used only for debugging purposes, and the * content and format of the returned string may vary between * implementations. The returned string may be empty but may not ! * be <code>null</code>. * ! * @return a string representation of this <code>JScrollPane</code>. */ protected String paramString() { String viewportBorderString = (viewportBorder != null ? viewportBorder.toString() : ""); String viewportString = (viewport != null ? --- 1346,1363 ---- } } /** ! * Returns a string representation of this {@code JScrollPane}. * This method * is intended to be used only for debugging purposes, and the * content and format of the returned string may vary between * implementations. The returned string may be empty but may not ! * be {@code null}. * ! * @return a string representation of this {@code JScrollPane}. */ protected String paramString() { String viewportBorderString = (viewportBorder != null ? viewportBorder.toString() : ""); String viewportString = (viewport != null ?
*** 1431,1451 **** return accessibleContext; } /** * This class implements accessibility support for the ! * <code>JScrollPane</code> class. It provides an implementation of the * Java Accessibility API appropriate to scroll pane user-interface * elements. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") // Same-version serialization only protected class AccessibleJScrollPane extends AccessibleJComponent implements ChangeListener, PropertyChangeListener { --- 1431,1451 ---- return accessibleContext; } /** * This class implements accessibility support for the ! * {@code JScrollPane} class. It provides an implementation of the * Java Accessibility API appropriate to scroll pane user-interface * elements. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") // Same-version serialization only protected class AccessibleJScrollPane extends AccessibleJComponent implements ChangeListener, PropertyChangeListener {
*** 1502,1512 **** } /** * Invoked when the target of the listener has changed its state. * ! * @param e a <code>ChangeEvent</code> object. Must not be null. * * @throws NullPointerException if the parameter is null. */ public void stateChanged(ChangeEvent e) { if (e == null) { --- 1502,1512 ---- } /** * Invoked when the target of the listener has changed its state. * ! * @param e a {@code ChangeEvent} object. Must not be null. * * @throws NullPointerException if the parameter is null. */ public void stateChanged(ChangeEvent e) { if (e == null) {
*** 1517,1527 **** Boolean.valueOf(true)); } /** * This method gets called when a bound property is changed. ! * @param e A <code>PropertyChangeEvent</code> object describing * the event source and the property that has changed. Must not be null. * * @throws NullPointerException if the parameter is null. * @since 1.5 */ --- 1517,1527 ---- Boolean.valueOf(true)); } /** * This method gets called when a bound property is changed. ! * @param e A {@code PropertyChangeEvent} object describing * the event source and the property that has changed. Must not be null. * * @throws NullPointerException if the parameter is null. * @since 1.5 */
< prev index next >