Java Reference
In-Depth Information
If you create a custom
Scrollable
component and then place that component in a
JScrollPane
, it will respond appropriately when the scrollbars for the
JScrollPane
or the
mouse wheel are moved.
JScrollPane Properties
Table 11-7 shows the 19 properties of
JScrollPane
.
Table 11-7.
JScrollPane Properties
Property Name
Data Type
Access
accessibleContext
AccessibleContext
Read-only
columnHeader
*
JViewport
Read-write bound
columnHeaderView
Component
Write-only
componentOrientation
ComponentOrientation
Write-only bound
horizontalScrollBar
*
JScrollBar
Read-write bound
horizontalScrollBarPolicy
*
int
Read-write bound
layout
LayoutManager
Write-only
rowHeader
*
JViewport
Read-write bound
rowHeaderView
Component
Write-only
UI
ScrollPaneUI
Read-write bound
UIClassID
String
Read-only
validateRoot
boolean
Read-only
verticalScrollBar
*
JScrollBar
Read-write bound
verticalScrollBarPolicy
*
int
Read-write bound
viewport
*
JViewport
Read-write bound
viewportBorder
Border
Read-write bound
viewportBorderBounds
Rectangle
Read-only
viewportView
Component
Write-only
wheelScrollingEnabled
boolean
Read-write bound
* These properties directly map to properties of the
ScrollPaneLayout
manager used by the
JScrollPane
.
Changing one of these properties for a
JScrollPane
causes its layout manager to change accordingly.
■
Caution
An attempt to change the layout property of
JScrollPane
to something other than a
ScrollPaneLayout
instance or
null
will throw a
ClassCastException
at runtime, because the
layout manager used by a
JScrollPane
must be a
ScrollPaneLayout
.