represents a graphical slider. Like scrollbars, sliders can have either
a horizontal or vertical orientation. With sliders, however, you can
enhance their appearance with tick marks and labels. The class hierarchy is illustrated in Figure 6-8. In most instances, a
slider is preferable to a standalone scrollbar. Sliders
represent a selection of one value from a bounded range. Scrollbars
represent a range of values within a bounded range and are best used in
things like the
Figure 6-8. JSlider class diagram
JSlider class allows you to
set the spacing of two types of tick marks: major and minor. Major tick
marks are longer than minor tick marks and are generally used at wider
intervals. Figure 6-9 shows
various sliders that can be composed in Swing.
Figure 6-9. Various sliders in Swing
setPaintTicks( ) method
boolean, which is used to
activate or deactivate the slider’s tick marks. In some L&Fs, the slider changes from a rectangular shape to a
pointer when tick marks are activated. This is often done to give the
user a more accurate representation of where the slider falls.
You can create a
Component objects to annotate the
slider. Each entry in the
consists of two fields: an
Integer key, which supplies ...