Java Reference
In-Depth Information
Working with ScrollPaneLayout
The JScrollPane relies on the ScrollPaneLayout manager for the positioning of components
within the container. Whereas most layout managers are designed to lay out any type of compo-
nent, all but four regions of ScrollPaneLayout accept a component of a specific type. Table 11-8
shows the type of component that can go into each of the regions shown in Figure 11-15.
Table 11-8. ScrollPaneLayout Locations
Location
Data Type
Description
COLUMN_HEADER
JViewport
Usually empty. If main content is a table, serves as column
headers that won't scroll as vertical scrollbar is moved.
HORIZONTAL_SCROLLBAR
JScrollBar
A scrollbar for the main content region placed below that
region.
LOWER_LEFT_CORNER
Component
Usually empty. For a graphic in the lower-left corner.
LOWER_RIGHT_CORNER
Component
Usually empty. For a graphic in the lower-right corner.
ROW_HEADER
JViewport
Usually empty. If main content is a table, serves as row
labels that won't scroll when horizontal scrollbar is
moved.
UPPER_LEFT_CORNER
Component
Usually empty. For a graphic in the upper-left corner.
UPPER_RIGHT_CORNER
Component
Usually empty. For a graphic in the upper-right corner.
VERTICAL_SCROLLBAR
JScrollBar
A scrollbar for the main content region, placed to the right
of the content area.
VIEWPORT
JViewport
The main content area.
Note The corners have two sets of constants. For internationalization support, you can use
LOWER_LEADING_CORNER , LOWER_TRAILING_CORNER , UPPER_LEADING_CORNER , and
UPPER_TRAILING_CORNER , which deal with component orientation for you. For left-to-right
component orientation (United States locale), leading is left, and trailing is right.
As designed, the layout manager describes the screen layout necessary to support a main
content area ( VIEWPORT ) that's too large for the available space. Scrollbars for navigating
through the area can be placed to the right of the content area ( VERTICAL_SCROLLBAR ) or below
it ( HORIZONTAL_SCROLLBAR ). Fixed headers that don't scroll can be placed above the content area
( COLUMN_HEADER ) or to its left ( ROW_HEADER ). The four corners ( *_CORNER ) are configurable to
display any type of component, which are typically labels with images on them; however, any
component can be placed there.
 
Search WWH ::




Custom Search