Next: An example using JScrollPane
Up: Swing Containers
Previous: A complete JTabbedPane example
A new class called JScrollPane
manages almost all aspects of a scrollable view.
This is a convenient component that makes managing on many aspects of scrolling easy:
- There is
no need to determine drawing rectangles,
- it is not necessary to intercept window movement
events.
- Scrollbars can be either horizontal
or vertical.
- The presence
of the scroll bars can be controlled either programmatically or automatically
(depending on the size of the window).
The most important point to make with an application utilizing a scrolling
view is that:
- The developer is responsible only for populating the pane.
- After this, Swing manages all of the movement, repainting, and resize activities
associated with the pane.
GUI Guideline
Favor vertical scrolling over horizontal scrolling in panes.
- Users tend not
to enjoy scrolling, but when users are forced into a scrolling situation, they
almost always scroll downward first rather than toward the right.
- Initially,
place the object being scrolled at the top-left most position, and then, place
more viewable information in a vertical path downward.
Dave Marshall
4/14/1999