All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.ajug.jsl.jester.ui.ProgressBar

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----javax.swing.JComponent
                           |
                           +----org.ajug.jsl.jester.ui.ProgressBar

public class ProgressBar
extends JComponent
implements ActionListener
This provides a simple progress bar. To use for Jester, set the maximum at the start of a suite run. Then as each test completes, increment the value to number of tests done. The default foreground color is Color.green. To indicate an exception has occurred, set the foregound color to Color.red. For simplicity the minimum is always zero.

To restart the progress bar for another suite run, simply set the foreground color to green, maximum to number of tests, and value to zero.

The unit test is java org.ajug.jsl.jester.ui.ProgressBar. See this for a simple demo of how to use this class.


Constructor Index

 o ProgressBar()
Creates a ProgressBar with a lowered bevel border and defaults.

Method Index

 o actionPerformed(ActionEvent)
Used for the unit test.
 o getBackgroundColor()
Returns the current background color.
 o getForegroundColor()
Returns the current foreground color.
 o getMaximum()
Returns the current maximum.
 o getMinimumSize()
 o getPreferredSize()
 o getValue()
Returns the current value, which is always in the zero to maximum range.
 o main(String[])
Runs the unit test.
 o paintComponent(Graphics)
Paints the component in the usual progress bar style.
 o runUnitTest()
Runs a simple unit test in a Frame.
 o setBackgroundColor(Color)
Sets the background color.
 o setBounds(int, int, int, int)
 o setForegroundColor(Color)
Sets the foreground color, which is used to display progress.
 o setMaximum(int)
Sets the maximum progress anticipated.
 o setSize(int, int)
 o setValue(int)
Sets the current value, which indicates progress relative to the maximum.

Constructors

 o ProgressBar
 public ProgressBar()
Creates a ProgressBar with a lowered bevel border and defaults.

Methods

 o setForegroundColor
 public void setForegroundColor(Color color)
Sets the foreground color, which is used to display progress. The default is Color.green.

 o getForegroundColor
 public Color getForegroundColor()
Returns the current foreground color.

 o setBackgroundColor
 public void setBackgroundColor(Color color)
Sets the background color. The default is Color.lightGray.

 o getBackgroundColor
 public Color getBackgroundColor()
Returns the current background color.

 o setValue
 public void setValue(int value)
Sets the current value, which indicates progress relative to the maximum. Setting the value will cause a repaint to show the new progress.

If the value is below zero it's automatically changed to zero. If above the maximum it's automatically changed to the maximum. This prevents unpredictable behavior in the progress bar and makes it easier to use.

 o getValue
 public int getValue()
Returns the current value, which is always in the zero to maximum range.

 o setMaximum
 public void setMaximum(int maximum)
Sets the maximum progress anticipated. This should be done before using the progress bar to display progress. The default is 10. Values below zero are not allowed.

 o getMaximum
 public int getMaximum()
Returns the current maximum.

 o main
 public static void main(String args[])
Runs the unit test.

 o paintComponent
 public void paintComponent(Graphics g)
Paints the component in the usual progress bar style. First the background is painted using the background color. Then the foreground is painted using the foreground color, but only the portion representing percent progress. This is calculated by the formula (value / maximum).

Overrides:
paintComponent in class JComponent
 o setSize
 public void setSize(int width,
                     int height)
Overrides:
setSize in class Component
 o setBounds
 public void setBounds(int x,
                       int y,
                       int width,
                       int height)
Overrides:
setBounds in class Component
 o getPreferredSize
 public Dimension getPreferredSize()
Overrides:
getPreferredSize in class JComponent
 o getMinimumSize
 public Dimension getMinimumSize()
Overrides:
getMinimumSize in class JComponent
 o actionPerformed
 public void actionPerformed(ActionEvent evt)
Used for the unit test.

 o runUnitTest
 public void runUnitTest()
Runs a simple unit test in a Frame. Clicking on the Increment button will cause the progress bar to advance one value.


All Packages  Class Hierarchy  This Package  Previous  Next  Index