Java Reference
In-Depth Information
Day 10 page. You also can use graphics from your own system, although they must be in
GIF format and reasonably small.
The toolbar in this application can be grabbed by its handle—the area immediately to the
left of the “Load” button in Figure 10.12. If you drag it within the window, you can dock
it along different edges of the application window. When you release the toolbar, the
application is rearranged using the border layout manager. You also can drag the toolbar
out of the application window entirely.
Although toolbars are most commonly used with graphical buttons, they can contain tex-
tual buttons, combo boxes, and other }components.
Progress Bars
Progress bars are components used to show how much time is left before a task is com-
plete.
10
Progress bars are implemented in Swing through the JProgressBar class. A sample Java
program that uses this component is shown in Figure 10.13.
FIGURE 10.13
A progress bar in
a frame.
Progress bars are used to track the progress of a task that can be represented numerically.
They are created by specifying a minimum and a maximum value that represent the
points at which the task is beginning and ending.
A software installation that consists of 335 different files is a good example of a task that
can be numerically quantified. The number of files transferred can be used to monitor the
progress of the task. The minimum value is 0 , and the maximum value is 335 .
Constructor methods include the following:
JProgressBar() —Creates a new progress bar
n
JProgressBar( int , int ) —Creates a new progress bar with the specified mini-
mum value and maximum value
n
JProgressBar( int , int , int ) —Creates a new progress bar with the specified
orientation, minimum value, and maximum value
n
The orientation of a progress bar can be established with the SwingConstants.VERTICAL
and SwingConstants.HORIZONTAL class constants. Progress bars are horizontal by
default.
Search WWH ::




Custom Search