JavaTM 2 Platform
Std. Ed. v1.3

javax.swing.plaf.basic
Class BasicProgressBarUI

java.lang.Object
  |
  +--javax.swing.plaf.ComponentUI
        |
        +--javax.swing.plaf.ProgressBarUI
              |
              +--javax.swing.plaf.basic.BasicProgressBarUI
Direct Known Subclasses:
MetalProgressBarUI

public class BasicProgressBarUI
extends ProgressBarUI

A Basic L&F implementation of ProgressBarUI.


Inner Class Summary
 class BasicProgressBarUI.ChangeHandler
          This inner class is marked "public" due to a compiler bug.
 
Field Summary
protected  ChangeListener changeListener
           
protected  JProgressBar progressBar
           
 
Constructor Summary
BasicProgressBarUI()
           
 
Method Summary
static ComponentUI createUI(JComponent x)
           
protected  int getAmountFull(Insets b, int width, int height)
          This determines the amount of the progress bar that should be filled based on the percent done gathered from the model.
protected  int getCellLength()
          Returns the width (if HORIZONTAL) or height (if VERTICAL) of each of the indivdual 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.
 Dimension getMaximumSize(JComponent c)
           
 Dimension getMinimumSize(JComponent c)
          The Minimum size for this component is 10.
protected  Dimension getPreferredInnerHorizontal()
           
protected  Dimension getPreferredInnerVertical()
           
 Dimension getPreferredSize(JComponent c)
           
protected  Color getSelectionBackground()
          The "selectionBackground" is the color of the text when it is drawn over an unfilled area of the progress bar.
protected  Color getSelectionForeground()
          The "selectionForeground" is the color of the text when it is drawn over a filled area of the progress bar.
protected  Point getStringPlacement(Graphics g, String progressString, int x, int y, int width, int height)
          Designate the place where the progress string will be drawn.
protected  void installDefaults()
           
protected  void installListeners()
           
 void installUI(JComponent c)
           
 void paint(Graphics g, JComponent c)
          All purpose paint method that should do the right thing for almost all linear progress bars.
protected  void paintString(Graphics g, int x, int y, int width, int height, int amountFull, Insets b)
           
protected  void setCellLength(int cellLen)
           
protected  void setCellSpacing(int cellSpace)
           
protected  void uninstallDefaults()
           
protected  void uninstallListeners()
           
 void uninstallUI(JComponent c)
           
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

progressBar

protected JProgressBar progressBar

changeListener

protected ChangeListener changeListener
Constructor Detail

BasicProgressBarUI

public BasicProgressBarUI()
Method Detail

createUI

public static ComponentUI createUI(JComponent x)

installUI

public void installUI(JComponent c)
Overrides:
installUI in class ComponentUI

uninstallUI

public void uninstallUI(JComponent c)
Overrides:
uninstallUI in class ComponentUI

installDefaults

protected void installDefaults()

uninstallDefaults

protected void uninstallDefaults()

installListeners

protected void installListeners()

uninstallListeners

protected void uninstallListeners()

getPreferredInnerHorizontal

protected Dimension getPreferredInnerHorizontal()

getPreferredInnerVertical

protected Dimension getPreferredInnerVertical()

getSelectionForeground

protected Color getSelectionForeground()
The "selectionForeground" is the color of the text when it is drawn over a filled area of the progress bar.

getSelectionBackground

protected Color getSelectionBackground()
The "selectionBackground" is the color of the text when it is drawn over an unfilled area of the progress bar.

getCellLength

protected int getCellLength()
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 value representing the spacing between cells
See Also:
setCellLength(int), JProgressBar.isStringPainted()

setCellLength

protected void setCellLength(int cellLen)

getCellSpacing

protected int getCellSpacing()
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 value representing the spacing between cells
See Also:
setCellSpacing(int), JProgressBar.isStringPainted()

setCellSpacing

protected void setCellSpacing(int cellSpace)

getAmountFull

protected int getAmountFull(Insets b,
                            int width,
                            int height)
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.

paint

public void paint(Graphics g,
                  JComponent c)
All purpose paint method that should do the right thing for almost all linear 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.
Overrides:
paint in class ComponentUI

paintString

protected void paintString(Graphics g,
                           int x,
                           int y,
                           int width,
                           int height,
                           int amountFull,
                           Insets b)

getStringPlacement

protected Point getStringPlacement(Graphics g,
                                   String progressString,
                                   int x,
                                   int y,
                                   int width,
                                   int height)
Designate the place where the progress string will be drawn. 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.

getPreferredSize

public Dimension getPreferredSize(JComponent c)
Overrides:
getPreferredSize in class ComponentUI

getMinimumSize

public Dimension getMinimumSize(JComponent c)
The Minimum size for this component is 10. The rationale here is that there should be at least one pixel per 10 percent.
Overrides:
getMinimumSize in class ComponentUI

getMaximumSize

public Dimension getMaximumSize(JComponent c)
Overrides:
getMaximumSize in class ComponentUI

JavaTM 2 Platform
Std. Ed. v1.3

Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.