A container for
JComponents that is typically placed at
the bottom of a form and runs the entire width of the form. There are 3
important functions that
JXStatusBar provides a hook for a pluggable look.
There is a definite look associated with status bars on windows, for instance.
By implementing a subclass of
JComponent, we provide a way for the
pluggable look and feel system to modify the look of the status bar.
JXStatusBar comes with its own layout manager. Each item is added to
JXStatusBar with a
as the constraint argument. The
Insets object, as well as a
which can be FIXED or FILL. The resize behaviour applies to the width of
components. All components added will maintain there preferred height, and the
height of the
JXStatusBar will be the height of the highest
component plus insets.
A constraint with
will cause the component to occupy a fixed area on the
The size of the area remains constant when the
JXStatusBar is resized.
A constraint with this behavior may also take a width value, see
JXStatusBar.Constraint#setFixedWidth(int). The width is a preferred
minimum width. If the component preferred width is greater than the constraint
width, the component width will apply.
All components with constraint
will share equally any spare space in the
JXStatusBar. Spare space
is that left over after allowing for all FIXED component and the preferred
width of FILL components, plus insets
JXStatusBar is very straightforward:
JXStatusBar bar = new JXStatusBar();
JLabel statusLabel = new JLabel("Ready");
JXStatusBar.Constraint c1 = new JXStatusBar.Constraint()
bar.add(statusLabel, c1); // Fixed width of 100 with no inserts
JXStatusBar.Constraint c2 = new JXStatusBarConstraint(
JXStatusBar.Constraint.ResizeBehavior.FILL) // Fill with no inserts
JProgressBar pbar = new JProgressBar();
bar.add(pbar, c2); // Fill with no inserts - will use remaining space
Two common use cases for status bars include tracking application status and
JXStatusBar does not manage these tasks, but instead special components
exist or can be created that do manage these tasks. For example, if your application
has a TaskManager or some other repository of currently running jobs, you could
easily create a TaskManagerProgressBar that tracks those jobs. This component
could then be added to the
JXStatusBar like any other component.
The BasicStatusBarUI.AUTO_ADD_SEPARATOR client property can be specified, which
will disable the auto-adding of separators. In this case, you must add your own
JSeparator components. To use:
JXStatusBar sbar = new JXStatusBar();