Class JScrollPane
- All Implemented Interfaces:
- ImageObserver,- MenuContainer,- Serializable,- Accessible,- ScrollPaneConstants
JScrollPane manages a viewport, optional
 vertical and horizontal scroll bars, and optional row and
 column heading viewports.
 You can find task-oriented documentation of JScrollPane in
  How to Use Scroll Panes,
 a section in The Java Tutorial.  Note that
 JScrollPane does not support heavyweight components.
 Example:
 
 
JViewport provides a window,
 or "viewport" onto a data
 source -- for example, a text file. That data source is the
 "scrollable client" (aka data model) displayed by the
 JViewport view.
 A JScrollPane basically consists of JScrollBars,
 a JViewport, and the wiring between them,
 as shown in the diagram at right.
 
 In addition to the scroll bars and viewport,
 a JScrollPane can have a
 column header and a row header. Each of these is a
 JViewport object that
 you specify with setRowHeaderView,
 and 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.
 
Where two scroll bars meet, the row header meets the column header, or a scroll bar meets one of the headers, both components stop short of the corner, leaving a rectangular space which is, by default, empty. 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".
 Any number of these empty spaces can be replaced by using the
 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.
 
 A corner component will only be visible if there is an empty space in that
 corner for it to exist in. For example, consider a component set into the
 top right corner of a scroll pane with a column header. If the scroll pane's
 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
 setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_ALWAYS),
 will ensure that the space for the corner component always exists.
 
 To add a border around the main viewport,
 you can use setViewportBorder.
 (Of course, you can also add a border around the whole scroll pane using
 setBorder.)
 
 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 scrollPane.getViewport().setBackground().
 The reason for setting the color of the viewport and not the scrollpane
 is that by default JViewport is opaque
 which, among other things, means it will completely fill
 in its background using its background color.  Therefore when
 JScrollPane draws its background the viewport will
 usually draw over it.
 
 By default JScrollPane uses ScrollPaneLayout
 to handle the layout of its child Components. ScrollPaneLayout
 determines the size to make the viewport view in one of two ways:
 
- If the view implements Scrollablea combination ofgetPreferredScrollableViewportSize,getScrollableTracksViewportWidthandgetScrollableTracksViewportHeightis used, otherwise
- getPreferredSizeis used.
Warning: Swing is not thread safe. For more information see Swing's Threading Policy.
 Warning:
 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
 has been added to the java.beans package.
 Please see XMLEncoder.
- Since:
- 1.2
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classThis class implements accessibility support for theJScrollPaneclass.protected classBy defaultJScrollPanecreates scrollbars that are instances of this class.Nested classes/interfaces declared in class javax.swing.JComponentJComponent.AccessibleJComponentNested classes/interfaces declared in class java.awt.ContainerContainer.AccessibleAWTContainerNested classes/interfaces declared in class java.awt.ComponentComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected JViewportThe column header child.protected JScrollBarThe scrollpane's horizontal scrollbar child.protected intThe display policy for the horizontal scrollbar.protected ComponentThe component to display in the lower left corner.protected ComponentThe component to display in the lower right corner.protected JViewportThe row header child.protected ComponentThe component to display in the upper left corner.protected ComponentThe component to display in the upper right corner.protected JScrollBarThe scrollpane's vertical scrollbar child.protected intThe display policy for the vertical scrollbar.protected JViewportThe scrollpane's viewport child.Fields declared in class javax.swing.JComponentlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields declared in class java.awt.ComponentaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields declared in interface java.awt.image.ImageObserverABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields declared in interface javax.swing.ScrollPaneConstantsCOLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
- 
Constructor SummaryConstructorsConstructorDescriptionCreates an empty (no viewport view)JScrollPanewhere both horizontal and vertical scrollbars appear when needed.JScrollPane(int vsbPolicy, int hsbPolicy) Creates an empty (no viewport view)JScrollPanewith specified scrollbar policies.JScrollPane(Component view) Creates aJScrollPanethat displays the contents of the specified component, where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view.JScrollPane(Component view, int vsbPolicy, int hsbPolicy) Creates aJScrollPanethat displays the view component in a viewport whose view position can be controlled with a pair of scrollbars.
- 
Method SummaryModifier and TypeMethodDescriptionReturns aJScrollPane.ScrollBarby default.Returns aJScrollPane.ScrollBarby default.protected JViewportReturns a newJViewportby default.Gets the AccessibleContext associated with this JScrollPane.Returns the column header.Returns the component at the specified corner.Returns the horizontal scroll bar that controls the viewport's horizontal view position.intReturns the horizontal scroll bar policy value.Returns the row header.getUI()Returns the look and feel (L&F) object that renders this component.Returns the suffix used to construct the name of the L&F class used to render this component.Returns the vertical scroll bar that controls the viewports vertical view position.intReturns the vertical scroll bar policy value.Returns the currentJViewport.Returns theBorderobject that surrounds the viewport.Returns the bounds of the viewport's border.booleanOverridden to return true so that any calls torevalidateon any descendants of thisJScrollPanewill cause the entire tree beginning with thisJScrollPaneto be validated.booleanIndicates whether or not scrolling will take place in response to the mouse wheel.protected StringReturns a string representation of thisJScrollPane.voidsetColumnHeader(JViewport columnHeader) Removes the old columnHeader, if it exists; if the new columnHeader isn'tnull, syncs the x coordinate of its viewPosition with the viewport (if there is one) and then adds it to the scroll pane.voidsetColumnHeaderView(Component view) Creates a column-header viewport if necessary, sets its view, and then adds the column-header viewport to the scrollpane.voidSets the orientation for the vertical and horizontal scrollbars as determined by theComponentOrientationargument.voidAdds a child that will appear in one of the scroll panes corners, if there's room.voidsetHorizontalScrollBar(JScrollBar horizontalScrollBar) Adds the scrollbar that controls the viewport's horizontal view position to the scrollpane.voidsetHorizontalScrollBarPolicy(int policy) Determines when the horizontal scrollbar appears in the scrollpane.voidsetLayout(LayoutManager layout) Sets the layout manager for thisJScrollPane.voidsetRowHeader(JViewport rowHeader) Removes the old rowHeader, if it exists; if the new rowHeader isn'tnull, syncs the y coordinate of its viewPosition with the viewport (if there is one) and then adds it to the scroll pane.voidsetRowHeaderView(Component view) Creates a row-header viewport if necessary, sets its view and then adds the row-header viewport to the scrollpane.voidsetUI(ScrollPaneUI ui) Sets theScrollPaneUIobject that provides the look and feel (L&F) for this component.voidsetVerticalScrollBar(JScrollBar verticalScrollBar) Adds the scrollbar that controls the viewports vertical view position to the scrollpane.voidsetVerticalScrollBarPolicy(int policy) Determines when the vertical scrollbar appears in the scrollpane.voidsetViewport(JViewport viewport) Removes the old viewport (if there is one); forces the viewPosition of the new viewport to be in the +x,+y quadrant; 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.voidsetViewportBorder(Border viewportBorder) Adds a border around the viewport.voidsetViewportView(Component view) Creates a viewport if necessary and then sets its view.voidsetWheelScrollingEnabled(boolean handleWheel) Enables/disables scrolling in response to movement of the mouse wheel.voidupdateUI()Replaces the currentScrollPaneUIobject with a version from the current default look and feel.Methods declared in class javax.swing.JComponentaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods declared in class java.awt.Containeradd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTreeMethods declared in class java.awt.Componentaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
- 
Field Details- 
verticalScrollBarPolicyprotected int verticalScrollBarPolicyThe display policy for the vertical scrollbar. The default isScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED.- See Also:
 
- 
horizontalScrollBarPolicyprotected int horizontalScrollBarPolicyThe display policy for the horizontal scrollbar. The default isScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED.- See Also:
 
- 
viewportThe scrollpane's viewport child. Default is an emptyJViewport.- See Also:
 
- 
verticalScrollBarThe scrollpane's vertical scrollbar child. Default is aJScrollBar.- See Also:
 
- 
horizontalScrollBarThe scrollpane's horizontal scrollbar child. Default is aJScrollBar.- See Also:
 
- 
rowHeader
- 
columnHeader
- 
lowerLeftThe component to display in the lower left corner. Default isnull.- See Also:
 
- 
lowerRightThe component to display in the lower right corner. Default isnull.- See Also:
 
- 
upperLeftThe component to display in the upper left corner. Default isnull.- See Also:
 
- 
upperRightThe component to display in the upper right corner. Default isnull.- See Also:
 
 
- 
- 
Constructor Details- 
JScrollPaneCreates aJScrollPanethat 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, ifvsbPolicyisVERTICAL_SCROLLBAR_AS_NEEDEDthen the vertical scrollbar only appears if the view doesn't fit vertically. The available policy settings are listed atsetVerticalScrollBarPolicy(int)andsetHorizontalScrollBarPolicy(int).- Parameters:
- view- the component to display in the scrollpanes viewport
- vsbPolicy- an integer that specifies the vertical scrollbar policy
- hsbPolicy- an integer that specifies the horizontal scrollbar policy
- See Also:
 
- 
JScrollPaneCreates aJScrollPanethat displays the contents of the specified component, where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view.- Parameters:
- view- the component to display in the scrollpane's viewport
- See Also:
 
- 
JScrollPanepublic JScrollPane(int vsbPolicy, int hsbPolicy) Creates an empty (no viewport view)JScrollPanewith specified scrollbar policies. The available policy settings are listed atsetVerticalScrollBarPolicy(int)andsetHorizontalScrollBarPolicy(int).- Parameters:
- vsbPolicy- an integer that specifies the vertical scrollbar policy
- hsbPolicy- an integer that specifies the horizontal scrollbar policy
- See Also:
 
- 
JScrollPanepublic JScrollPane()Creates an empty (no viewport view)JScrollPanewhere both horizontal and vertical scrollbars appear when needed.
 
- 
- 
Method Details- 
getUI@BeanProperty(hidden=true, visualUpdate=true, description="The UI object that implements the Component's LookAndFeel.") public ScrollPaneUI getUI()Returns the look and feel (L&F) object that renders this component.- Overrides:
- getUIin class- JComponent
- Returns:
- the ScrollPaneUIobject that renders this component
- See Also:
 
- 
setUISets theScrollPaneUIobject that provides the look and feel (L&F) for this component.- Parameters:
- ui- the- ScrollPaneUIL&F object
- See Also:
 
- 
updateUIpublic void updateUI()Replaces the currentScrollPaneUIobject with a version from the current default look and feel. To be called when the default look and feel changes.- Overrides:
- updateUIin class- JComponent
- See Also:
 
- 
getUIClassIDReturns the suffix used to construct the name of the L&F class used to render this component.- Overrides:
- getUIClassIDin class- JComponent
- Returns:
- the string "ScrollPaneUI"
- See Also:
 
- 
setLayoutSets the layout manager for thisJScrollPane. This method overridessetLayoutinjava.awt.Containerto ensure that onlyLayoutManagers which are subclasses ofScrollPaneLayoutcan be used in aJScrollPane. Iflayoutis non-null, this will invokesyncWithScrollPaneon it.- Overrides:
- setLayoutin class- Container
- Parameters:
- layout- the specified layout manager
- Throws:
- ClassCastException- if layout is not a- ScrollPaneLayout
- See Also:
 
- 
isValidateRootOverridden to return true so that any calls torevalidateon any descendants of thisJScrollPanewill cause the entire tree beginning with thisJScrollPaneto be validated.- Overrides:
- isValidateRootin class- JComponent
- Returns:
- true
- See Also:
 
- 
getVerticalScrollBarPolicypublic int getVerticalScrollBarPolicy()Returns the vertical scroll bar policy value.- Returns:
- the verticalScrollBarPolicyproperty
- See Also:
 
- 
setVerticalScrollBarPolicy@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) Determines when the vertical scrollbar appears in the scrollpane. Legal values are:- ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
- ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER
- ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
 - Parameters:
- policy- one of the three values listed above
- Throws:
- IllegalArgumentException- if- policyis not one of the legal values shown above
- See Also:
 
- 
getHorizontalScrollBarPolicypublic int getHorizontalScrollBarPolicy()Returns the horizontal scroll bar policy value.- Returns:
- the horizontalScrollBarPolicyproperty
- See Also:
 
- 
setHorizontalScrollBarPolicy@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) Determines when the horizontal scrollbar appears in the scrollpane. The options are:- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS
 - Parameters:
- policy- one of the three values listed above
- Throws:
- IllegalArgumentException- if- policyis not one of the legal values shown above
- See Also:
 
- 
getViewportBorderReturns theBorderobject that surrounds the viewport.- Returns:
- the viewportBorderproperty
- See Also:
 
- 
setViewportBorder@BeanProperty(preferred=true, description="The border around the viewport.") public void setViewportBorder(Border viewportBorder) Adds a border around the viewport. Note that the border isn't set on the viewport directly,JViewportdoesn't support theJComponentborder property. Similarly setting theJScrollPanes viewport doesn't affect theviewportBorderproperty.The default value of this property is computed by the look and feel implementation. - Parameters:
- viewportBorder- the border to be added
- See Also:
 
- 
getViewportBorderBoundsReturns the bounds of the viewport's border.- Returns:
- a Rectangleobject specifying the viewport border
 
- 
createHorizontalScrollBarReturns aJScrollPane.ScrollBarby default. Subclasses may override this method to forceScrollPaneUIimplementations to use aJScrollBarsubclass. Used byScrollPaneUIimplementations to create the horizontal scrollbar.- Returns:
- a JScrollBarwith a horizontal orientation
- See Also:
 
- 
getHorizontalScrollBarReturns the horizontal scroll bar that controls the viewport's horizontal view position.- Returns:
- the horizontalScrollBarproperty
- See Also:
 
- 
setHorizontalScrollBar@BeanProperty(expert=true, description="The horizontal scrollbar.") public void setHorizontalScrollBar(JScrollBar horizontalScrollBar) Adds the scrollbar that controls the viewport's horizontal view position to the scrollpane. This is usually unnecessary, asJScrollPanecreates horizontal and vertical scrollbars by default.- Parameters:
- horizontalScrollBar- the horizontal scrollbar to be added
- See Also:
 
- 
createVerticalScrollBarReturns aJScrollPane.ScrollBarby default. Subclasses may override this method to forceScrollPaneUIimplementations to use aJScrollBarsubclass. Used byScrollPaneUIimplementations to create the vertical scrollbar.- Returns:
- a JScrollBarwith a vertical orientation
- See Also:
 
- 
getVerticalScrollBarReturns the vertical scroll bar that controls the viewports vertical view position.- Returns:
- the verticalScrollBarproperty
- See Also:
 
- 
setVerticalScrollBar@BeanProperty(expert=true, description="The vertical scrollbar.") public void setVerticalScrollBar(JScrollBar verticalScrollBar) Adds the scrollbar that controls the viewports vertical view position to the scrollpane. This is usually unnecessary, asJScrollPanecreates vertical and horizontal scrollbars by default.- Parameters:
- verticalScrollBar- the new vertical scrollbar to be added
- See Also:
 
- 
createViewportReturns a newJViewportby default. Used to create the viewport (as needed) insetViewportView,setRowHeaderView, andsetColumnHeaderView. Subclasses may override this method to return a subclass ofJViewport.- Returns:
- a new JViewport
 
- 
getViewportReturns the currentJViewport.- Returns:
- the viewportproperty
- See Also:
 
- 
setViewport@BeanProperty(expert=true, visualUpdate=true, description="The viewport child for this scrollpane") public void setViewport(JViewport viewport) Removes the old viewport (if there is one); forces the viewPosition of the new viewport to be in the +x,+y quadrant; 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.Most applications will find it more convenient to use setViewportViewto add a viewport and a view to the scrollpane.- Parameters:
- viewport- the new viewport to be used; if viewport is- null, the old viewport is still removed and the new viewport is set to- null
- See Also:
 
- 
setViewportViewCreates a viewport if necessary and then sets its view. Applications that don't provide the view directly to theJScrollPaneconstructor should use this method to specify the scrollable child that's going to be displayed in the scrollpane. For example:JScrollPane scrollpane = new JScrollPane(); scrollpane.setViewportView(myBigComponentToScroll); Applications should not add children directly to the scrollpane.- Parameters:
- view- the component to add to the viewport
- See Also:
 
- 
getRowHeader
- 
setRowHeader@BeanProperty(expert=true, description="The row header child for this scrollpane") public void setRowHeader(JViewport rowHeader) Removes the old rowHeader, if it exists; if the new rowHeader isn'tnull, syncs the y coordinate of its viewPosition with the viewport (if there is one) and then adds it to the scroll pane.Most applications will find it more convenient to use setRowHeaderViewto add a row header component and its viewport to the scroll pane.- Parameters:
- rowHeader- the new row header to be used; if- nullthe old row header is still removed and the new rowHeader is set to- null
- See Also:
 
- 
setRowHeaderViewCreates a row-header viewport if necessary, sets its view and then adds the row-header viewport to the scrollpane. For example:JScrollPane scrollpane = new JScrollPane(); scrollpane.setViewportView(myBigComponentToScroll); scrollpane.setRowHeaderView(myBigComponentsRowHeader); - Parameters:
- view- the component to display as the row header
- See Also:
 
- 
getColumnHeaderReturns the column header.- Returns:
- the columnHeaderproperty
- See Also:
 
- 
setColumnHeader@BeanProperty(visualUpdate=true, description="The column header child for this scrollpane") public void setColumnHeader(JViewport columnHeader) Removes the old columnHeader, if it exists; if the new columnHeader isn'tnull, syncs the x coordinate of its viewPosition with the viewport (if there is one) and then adds it to the scroll pane.Most applications will find it more convenient to use setColumnHeaderViewto add a column header component and its viewport to the scroll pane.- Parameters:
- columnHeader- a- JViewportwhich is the new column header
- See Also:
 
- 
setColumnHeaderViewCreates a column-header viewport if necessary, sets its view, and then adds the column-header viewport to the scrollpane. For example:JScrollPane scrollpane = new JScrollPane(); scrollpane.setViewportView(myBigComponentToScroll); scrollpane.setColumnHeaderView(myBigComponentsColumnHeader); - Parameters:
- view- the component to display as the column header
- See Also:
 
- 
getCornerReturns the component at the specified corner. Thekeyvalue specifying the corner is one of:- ScrollPaneConstants.LOWER_LEFT_CORNER
- ScrollPaneConstants.LOWER_RIGHT_CORNER
- ScrollPaneConstants.UPPER_LEFT_CORNER
- ScrollPaneConstants.UPPER_RIGHT_CORNER
- ScrollPaneConstants.LOWER_LEADING_CORNER
- ScrollPaneConstants.LOWER_TRAILING_CORNER
- ScrollPaneConstants.UPPER_LEADING_CORNER
- ScrollPaneConstants.UPPER_TRAILING_CORNER
 - Parameters:
- key- one of the values as shown above
- Returns:
- the corner component (which may be null) identified by the given key, ornullif the key is invalid
- See Also:
 
- 
setCornerAdds a child that will appear in one of the scroll panes corners, if there's room. For example with both scrollbars showing (on the right and bottom edges of the scrollpane) the lower left corner component will be shown in the space between ends of the two scrollbars. Legal values for the key are:- ScrollPaneConstants.LOWER_LEFT_CORNER
- ScrollPaneConstants.LOWER_RIGHT_CORNER
- ScrollPaneConstants.UPPER_LEFT_CORNER
- ScrollPaneConstants.UPPER_RIGHT_CORNER
- ScrollPaneConstants.LOWER_LEADING_CORNER
- ScrollPaneConstants.LOWER_TRAILING_CORNER
- ScrollPaneConstants.UPPER_LEADING_CORNER
- ScrollPaneConstants.UPPER_TRAILING_CORNER
 Although "corner" doesn't match any beans property signature, PropertyChangeevents are generated with the property name set to the corner key.- Parameters:
- key- identifies which corner the component will appear in
- corner- one of the following components:- lowerLeft
- lowerRight
- upperLeft
- upperRight
 
- Throws:
- IllegalArgumentException- if corner key is invalid
 
- 
setComponentOrientationSets the orientation for the vertical and horizontal scrollbars as determined by theComponentOrientationargument.- Overrides:
- setComponentOrientationin class- Component
- Parameters:
- co- one of the following values:- java.awt.ComponentOrientation.LEFT_TO_RIGHT
- java.awt.ComponentOrientation.RIGHT_TO_LEFT
- java.awt.ComponentOrientation.UNKNOWN
 
- See Also:
 
- 
isWheelScrollingEnabled@BeanProperty(description="Flag for enabling/disabling mouse wheel scrolling") public boolean isWheelScrollingEnabled()Indicates whether or not scrolling will take place in response to the mouse wheel. Wheel scrolling is enabled by default.- Returns:
- true if mouse wheel scrolling is enabled, false otherwise
- Since:
- 1.4
- See Also:
 
- 
setWheelScrollingEnabled@BeanProperty(description="Flag for enabling/disabling mouse wheel scrolling") public void setWheelScrollingEnabled(boolean handleWheel) Enables/disables scrolling in response to movement of the mouse wheel. Wheel scrolling is enabled by default.- Parameters:
- handleWheel-- trueif scrolling should be done automatically for a MouseWheelEvent,- falseotherwise.
- Since:
- 1.4
- See Also:
 
- 
paramStringReturns a string representation of thisJScrollPane. 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 benull.- Overrides:
- paramStringin class- JComponent
- Returns:
- a string representation of this JScrollPane.
 
- 
getAccessibleContextGets the AccessibleContext associated with this JScrollPane. For scroll panes, the AccessibleContext takes the form of an AccessibleJScrollPane. A new AccessibleJScrollPane instance is created if necessary.- Specified by:
- getAccessibleContextin interface- Accessible
- Overrides:
- getAccessibleContextin class- Component
- Returns:
- an AccessibleJScrollPane that serves as the AccessibleContext of this JScrollPane
 
 
-