The JScrollBar Class
JScrollBar
is the Swing implementation of a scrollbar. The JScrollBar
class is shown in various
L&Fs in Figure
6-3.
Figure 6-3. Scrollbars in several L&Fs
To program with a scrollbar, it is important to understand its anatomy. Scrollbars are composed of a rectangular tab, called a slider or thumb , located between two arrow buttons. The arrow buttons on either end increment or decrement the slider’s position by an adjustable number of units, generally one. In addition, clicking in the area between the thumb and the end buttons (often called the paging area) moves the slider one block, or 10 units by default. The user can modify the value of the scrollbar in one of three ways: by dragging the thumb in either direction, by pushing on either of the arrow buttons, or by clicking in the paging area.
Scrollbars can have one of two orientations: horizontal or
vertical. Figure 6-4 provides
an illustration of a horizontal scrollbar. JScrollBar
uses the bounded-range model to
represent the scrollbar’s data. The assignment of each bounded-range
property is also shown in Figure
6-5. The minimum and maximum of the scrollbar fall on the
interior edges of the arrow buttons. The scrollbar’s value is defined as
the left (or top) edge of the slider. Finally, the extent of the
scrollbar defines the width of the thumb in relation to the total range.
(The older Adjustable
interface ...
Get Java Swing, 2nd 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.