Java Reference
In-Depth Information
JViewport Class
The JViewport component is rarely used on its own outside a JScrollPane . It normally lives
within the center of a JScrollPane and uses the ViewportLayout manager to respond to posi-
tioning requests to display a part of a large Component within a smaller space. In addition to
residing in the center of a JScrollPane , JViewport is also used for the row and column headers
of a JScrollPane .
Creating a JViewport
There's only one constructor for creating a JViewport : the no-argument version: public
JViewport() . Once you've created the JViewport , you place a component within it by using
setView(Component) .
JViewport Properties
Table 11-10 shows the 13 properties of JViewport . Setting the layout manager to something
other than ViewportLayout is possible but not recommended because the layout manager
makes the JViewport do its work properly.
Table 11-10. JViewport Properties
Property Name
Data Type
Access
accessibleContext
AccessibleContext
Read-only
border
Border
Write-only
changeListeners
ChangeListener[ ]
Read-only
extentSize
Dimension
Read-write
insets
Insets
Read-only
optimizedDrawingEnabled
boolean
Read-only
scrollMode
int
Read-write
UI
ViewportUI
Read-write bound
UIClassID
String
Read-only
view
Component
Read-write
viewPosition
Point
Read-write
viewRect
Rectangle
Read-only
viewSize
Dimension
Read-write
Because of scrolling complexity and for performance reasons, the JViewport doesn't support
a border. Trying to change the border to a non- null value with setBorder(Border) throws an
Search WWH ::




Custom Search