MetalProgressBarUI
, SynthProgressBarUI
public class BasicProgressBarUI extends ProgressBarUI
Modifier and Type | Class | Description |
---|---|---|
class |
BasicProgressBarUI.ChangeHandler |
This class should be treated as a "protected" inner class. |
Modifier and Type | Field | Description |
---|---|---|
protected Rectangle |
boxRect |
Used to hold the location and size of the bouncing box (returned by getBox) to be painted. |
protected ChangeListener |
changeListener |
The instance of ChangeListener . |
protected JProgressBar |
progressBar |
The instance of JProgressBar . |
Constructor | Description |
---|---|
BasicProgressBarUI() |
Constructs a BasicProgressBarUI . |
Modifier and Type | Method | Description |
---|---|---|
static ComponentUI |
createUI |
Returns a new instance of BasicProgressBarUI . |
protected int |
getAmountFull |
This determines the amount of the progress bar that should be filled based on the percent done gathered from the model. |
protected int |
getAnimationIndex() |
Gets the index of the current animation frame. |
int |
getBaseline |
Returns the baseline. |
Component.BaselineResizeBehavior |
getBaselineResizeBehavior |
Returns an enum indicating how the baseline of the component changes as the size changes. |
protected Rectangle |
getBox |
Stores the position and size of the bouncing box that would be painted for the current animation index in r and returns r . |
protected int |
getBoxLength |
Returns the length of the "bouncing box" to be painted. |
protected int |
getCellLength() |
Returns the width (if HORIZONTAL) or height (if VERTICAL) of each of the individual cells/units to be rendered in the progress bar. |
protected int |
getCellSpacing() |
Returns the spacing between each of the cells/units in the progress bar. |
protected final int |
getFrameCount() |
Returns the number of frames for the complete animation loop used by an indeterminate JProgessBar. |
Dimension |
getMinimumSize |
The Minimum size for this component is 10. |
protected Dimension |
getPreferredInnerHorizontal() |
Returns preferred size of the horizontal JProgressBar . |
protected Dimension |
getPreferredInnerVertical() |
Returns preferred size of the vertical JProgressBar . |
protected Color |
getSelectionBackground() |
The "selectionBackground" is the color of the text when it is painted over an unfilled area of the progress bar. |
protected Color |
getSelectionForeground() |
The "selectionForeground" is the color of the text when it is painted over a filled area of the progress bar. |
protected Point |
getStringPlacement |
Designate the place where the progress string will be painted. |
protected void |
incrementAnimationIndex() |
Sets the index of the current animation frame, to the next valid value, which results in the progress bar being repainted. |
protected void |
installDefaults() |
Installs default properties. |
protected void |
installListeners() |
Registers listeners. |
void |
paint |
Delegates painting to one of two methods: paintDeterminate or paintIndeterminate. |
protected void |
paintDeterminate |
All purpose paint method that should do the right thing for almost all linear, determinate progress bars. |
protected void |
paintIndeterminate |
All purpose paint method that should do the right thing for all linear bouncing-box progress bars. |
protected void |
paintString |
Paints the progress string. |
protected void |
setAnimationIndex |
Sets the index of the current animation frame to the specified value and requests that the progress bar be repainted. |
protected void |
setCellLength |
Sets the cell length. |
protected void |
setCellSpacing |
Sets the cell spacing. |
protected void |
startAnimationTimer() |
Starts the animation thread, creating and initializing it if necessary. |
protected void |
stopAnimationTimer() |
Stops the animation thread. |
protected void |
uninstallDefaults() |
Unintalls default properties. |
protected void |
uninstallListeners() |
Removes all listeners installed by this object. |
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getPreferredSize, installUI, uninstallUI, update
protected JProgressBar progressBar
JProgressBar
.protected ChangeListener changeListener
ChangeListener
.protected Rectangle boxRect
public BasicProgressBarUI()
BasicProgressBarUI
.public static ComponentUI createUI(JComponent x)
BasicProgressBarUI
.x
- a componentBasicProgressBarUI
protected void installDefaults()
protected void uninstallDefaults()
protected void installListeners()
protected void startAnimationTimer()
protected void stopAnimationTimer()
protected void uninstallListeners()
public int getBaseline(JComponent c, int width, int height)
getBaseline
in class ComponentUI
c
- JComponent
baseline is being requested forwidth
- the width to get the baseline forheight
- the height to get the baseline forNullPointerException
- if c
is null
IllegalArgumentException
- if width or height is < 0public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
getBaselineResizeBehavior
in class ComponentUI
c
- JComponent
to return baseline resize behavior forNullPointerException
- if c
is null
protected Dimension getPreferredInnerHorizontal()
JProgressBar
.JProgressBar
protected Dimension getPreferredInnerVertical()
JProgressBar
.JProgressBar
protected Color getSelectionForeground()
protected Color getSelectionBackground()
protected int getCellLength()
protected void setCellLength(int cellLen)
cellLen
- a new cell lengthprotected int getCellSpacing()
protected void setCellSpacing(int cellSpace)
cellSpace
- a new cell spacingprotected int getAmountFull(Insets b, int width, int height)
b
- insetswidth
- a widthheight
- a heightpublic void paint(Graphics g, JComponent c)
paint
in class ComponentUI
g
- the Graphics
context in which to paintc
- the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentsprotected Rectangle getBox(Rectangle r)
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 rectangleprotected int getBoxLength(int availableLength, int otherDimension)
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 valueavailableLength
protected void paintIndeterminate(Graphics g, JComponent c)
g
- an instance of Graphics
c
- a componentprotected void paintDeterminate(Graphics g, JComponent c)
g
- an instance of Graphics
c
- a componentprotected void paintString(Graphics g, int x, int y, int width, int height, int amountFull, Insets b)
g
- an instance of Graphics
x
- X location of bounding boxy
- Y location of bounding boxwidth
- width of bounding boxheight
- height of bounding boxamountFull
- size of the fill region, either width or height depending upon orientation.b
- Insets of the progress bar.protected Point getStringPlacement(Graphics g, String progressString, int x, int y, int width, int height)
g
- an instance of Graphics
progressString
- a textx
- an X coordinatey
- an Y coordinatewidth
- a widthheight
- a heightpublic Dimension getMinimumSize(JComponent c)
getMinimumSize
in class ComponentUI
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 componentsDimension
object or null
protected int getAnimationIndex()
protected final int getFrameCount()
protected void setAnimationIndex(int newValue)
repaint
method is invoked.newValue
- the new animation index; no checking is performed on its valueprotected void incrementAnimationIndex()
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/plaf/basic/BasicProgressBarUI.html