Chapter 6. Bounded Range Components
This chapter groups several Swing
components together by the model that drives them: the
bounded-range model. Bounded-range components
in Swing include JSlider,
JProgressBar, and JScrollBar.
In addition, we discuss two classes that make use of progress bars:
ProgressMonitor and
ProgressMonitorInputStream. These classes display
status dialogs using a JOptionPane that you can
assign to a variety of tasks.
The Bounded-Range Model
Components that make use of the bounded-range model typically consist of an integer value that is constrained within two integer boundaries. The lower boundary, the minimum , should always be less than or equal to the model’s current value. In addition, the model’s value should always be less than the upper boundary, the maximum. The model’s value can cover more than one unit; this size is referred to as its extent . With bounded range, the user is allowed to adjust the value of the model according to the rules of the component. If the value violates any of the rules, the model can adjust the values accordingly.
The interface
javax.swing.BoundedRangeModel
outlines the data model for such an object. The interface is very
similar to the java.awt.Adjustable interface
presented in AWT 1.1 and retains many of its
characteristics. Objects implementing the
BoundedRangeModel interface must contain an
adjustable integer value, an extent, and a minimum and maximum. Swing
contains three bounded-range components:
JScrollBar, JSlider ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access