13.22. Scrollbars and Sliders

The AWT uses the same basic component for scrollbars (used to scroll windows) and sliders (used to interactively select values): the Scrollbar class. The “preferred” size and shape of a Scrollbar is not generally usable, so scrollbars are not usually placed in a window that uses FlowLayout. Instead, they are typically placed in the east or south sections of a BorderLayout, used in a GridLayout, or resized by hand.

Unfortunately, scrollbars are not implemented in the same manner on all Java systems and are painful to use directly. The preferred alternative is to use TextAreas and ScrollPanes, unless you want sliders. If you are developing a Swing applet or application, the JSlider class (Section 14.7) is a significant ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.