java.lang.Object | |||
↳ | javax.swing.plaf.ComponentUI | ||
↳ | javax.swing.plaf.ProgressBarUI | ||
↳ | javax.swing.plaf.basic.BasicProgressBarUI |
![]() |
A Basic L&F implementation of ProgressBarUI.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
BasicProgressBarUI.ChangeHandler | This inner class is marked "public" due to a compiler bug. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boxRect | Used to hold the location and size of the bouncing box (returned by getBox) to be painted. | ||||||||||
changeListener | |||||||||||
progressBar |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the baseline.
| |||||||||||
Returns an enum indicating how the baseline of the component
changes as the size changes.
| |||||||||||
Returns the specified component's maximum size appropriate for
the look and feel.
| |||||||||||
The Minimum size for this component is 10.
| |||||||||||
Returns the specified component's preferred size appropriate for
the look and feel.
| |||||||||||
Configures the specified component appropriate for the look and feel.
| |||||||||||
Delegates painting to one of two methods:
paintDeterminate or paintIndeterminate.
| |||||||||||
Reverses configuration which was done on the specified component during
installUI . |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This determines the amount of the progress bar that should be filled
based on the percent done gathered from the model.
| |||||||||||
Gets the index of the current animation frame.
| |||||||||||
Stores the position and size of
the bouncing box that would be painted for the current animation index
in
r and returns r . | |||||||||||
Returns the length
of the "bouncing box" to be painted.
| |||||||||||
Returns the width (if HORIZONTAL) or height (if VERTICAL)
of each of the indivdual cells/units to be rendered in the
progress bar.
| |||||||||||
Returns the spacing between each of the cells/units in the
progress bar.
| |||||||||||
Returns the number of frames for the complete animation loop
used by an indeterminate JProgessBar.
| |||||||||||
The "selectionBackground" is the color of the text when it is painted
over an unfilled area of the progress bar.
| |||||||||||
The "selectionForeground" is the color of the text when it is painted
over a filled area of the progress bar.
| |||||||||||
Designate the place where the progress string will be painted.
| |||||||||||
Sets the index of the current animation frame,
to the next valid value,
which results in the progress bar being repainted.
| |||||||||||
All purpose paint method that should do the right thing for almost
all linear, determinate progress bars.
| |||||||||||
All purpose paint method that should do the right thing for all
linear bouncing-box progress bars.
| |||||||||||
Sets the index of the current animation frame
to the specified value and requests that the
progress bar be repainted.
| |||||||||||
Starts the animation thread, creating and initializing
it if necessary.
| |||||||||||
Stops the animation thread.
| |||||||||||
Removes all listeners installed by this object.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Used to hold the location and size of the bouncing box (returned by getBox) to be painted.
Returns the baseline.
c | JComponent baseline is being requested for |
---|---|
width | the width to get the baseline for |
height | the height to get the baseline for |
Returns an enum indicating how the baseline of the component changes as the size changes.
c | JComponent to return baseline resize behavior for |
---|
NullPointerException |
---|
Returns the specified component's maximum size appropriate for
the look and feel. If null
is returned, the maximum
size will be calculated by the component's layout manager instead
(this is the preferred approach for any component with a specific
layout manager installed). The default implementation of this
method invokes getPreferredSize
and returns that value.
c | the component whose maximum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
---|
Dimension
object or null
The Minimum size for this component is 10. The rationale here is that there should be at least one pixel per 10 percent.
c | the component whose minimum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
---|
Dimension
object or null
Returns the specified component's preferred size appropriate for
the look and feel. If null
is returned, the preferred
size will be calculated by the component's layout manager instead
(this is the preferred approach for any component with a specific
layout manager installed). The default implementation of this
method returns null
.
c | the component whose preferred size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
---|
Configures the specified component appropriate for the look and feel.
This method is invoked when the ComponentUI
instance is being installed
as the UI delegate on the specified component. This method should
completely configure the component for the look and feel,
including the following:
LayoutManager
on the component if necessary.
PropertyChangeListener
on the component in order
to detect and respond to component property changes appropriately.
c | the component where this UI delegate is being installed |
---|
Delegates painting to one of two methods: paintDeterminate or paintIndeterminate.
g | the Graphics context in which to paint |
---|---|
c | the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
Reverses configuration which was done on the specified component during
installUI
. This method is invoked when this
UIComponent
instance is being removed as the UI delegate
for the specified component. This method should undo the
configuration performed in installUI
, being careful to
leave the JComponent
instance in a clean state (no
extraneous listeners, look-and-feel-specific property objects, etc.).
This should include the following:
c | the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components |
---|
This determines the amount of the progress bar that should be filled based on the percent done gathered from the model. This is a common operation so it was abstracted out. It assumes that your progress bar is linear. That is, if you are making a circular progress indicator, you will want to override this method.
Gets the index of the current animation frame.
Stores the position and size of
the bouncing box that would be painted for the current animation index
in r
and returns r
.
Subclasses that add to the painting performed
in this class's implementation of paintIndeterminate
--
to draw an outline around the bouncing box, for example --
can use this method to get the location of the bouncing
box that was just painted.
By overriding this method,
you have complete control over the size and position
of the bouncing box,
without having to reimplement paintIndeterminate
.
r | the Rectangle instance to be modified;
may be null |
---|
null
if no box should be drawn;
otherwise, returns the passed-in rectangle
(if non-null)
or a new rectangleReturns the length
of the "bouncing box" to be painted.
This method is invoked by the
default implementation of paintIndeterminate
to get the width (if the progress bar is horizontal)
or height (if vertical) of the box.
For example:
boxRect.width = getBoxLength(componentInnards.width, componentInnards.height);
availableLength | the amount of space available for the bouncing box to move in; for a horizontal progress bar, for example, this should be the inside width of the progress bar (the component width minus borders) |
---|---|
otherDimension | for a horizontal progress bar, this should be the inside height of the progress bar; this value might be used to constrain or determine the return value |
availableLength
Returns the width (if HORIZONTAL) or height (if VERTICAL) of each of the indivdual cells/units to be rendered in the progress bar. However, for text rendering simplification and aesthetic considerations, this function will return 1 when the progress string is being rendered.
Returns the spacing between each of the cells/units in the progress bar. However, for text rendering simplification and aesthetic considerations, this function will return 0 when the progress string is being rendered.
Returns the number of frames for the complete animation loop used by an indeterminate JProgessBar. The progress chunk will go from one end to the other and back during the entire loop. This visual behavior may be changed by subclasses in other Look and Feels.
The "selectionBackground" is the color of the text when it is painted over an unfilled area of the progress bar.
The "selectionForeground" is the color of the text when it is painted over a filled area of the progress bar.
Designate the place where the progress string will be painted. This implementation places it at the center of the progress bar (in both x and y). Override this if you want to right, left, top, or bottom align the progress string or if you need to nudge it around for any reason.
Sets the index of the current animation frame, to the next valid value, which results in the progress bar being repainted. The next valid value is, by default, the current animation index plus one. If the new value would be too large, this method sets the index to 0. Subclasses might need to override this method to ensure that the index does not go over the number of frames needed for the particular progress bar instance. This method is invoked by the default animation thread every X milliseconds, where X is specified by the "ProgressBar.repaintInterval" UI default.
All purpose paint method that should do the right thing for almost all linear, determinate progress bars. By setting a few values in the defaults table, things should work just fine to paint your progress bar. Naturally, override this if you are making a circular or semi-circular progress bar.
All purpose paint method that should do the right thing for all linear bouncing-box progress bars. Override this if you are making another kind of progress bar.
Sets the index of the current animation frame
to the specified value and requests that the
progress bar be repainted.
Subclasses that don't use the default painting code
might need to override this method
to change the way that the repaint
method
is invoked.
newValue | the new animation index; no checking is performed on its value |
---|
Starts the animation thread, creating and initializing it if necessary. This method is invoked when an indeterminate progress bar should start animating. Reasons for this may include:
Stops the animation thread. This method is invoked when the indeterminate animation should be stopped. Reasons for this may include:
Removes all listeners installed by this object.