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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.