FileDocCategorySizeDatePackage
ProgressBar.javaAPI DocExample1172Mon Feb 23 16:15:42 GMT 1998oreilly.jonathan.awt

ProgressBar

public class ProgressBar extends Canvas

Fields Summary
int
mLevel
int
mMaximum
Color
mFrameColor
Constructors Summary
public ProgressBar()

 this(100); 
public ProgressBar(int max)

    setForeground(Color.blue);
    mFrameColor = Color.black;
    setMaximum(max);
    setLevel(0);
  
Methods Summary
public java.awt.DimensiongetMinimumSize()

 return new Dimension(10, 1); 
public java.awt.DimensiongetPreferredSize()

 return new Dimension(100, 10); 
public voidpaint(java.awt.Graphics g)

    Dimension d = getSize();
    double ratio = (double)((double)mLevel / (double)mMaximum);
    int x = (int)((double)d.width * ratio);

    g.setColor(mFrameColor);
    g.drawRect(0, 0, d.width - 1, d.height - 1);

    g.setColor(getForeground());
    g.fillRect(1, 1, x, d.height - 2);

    g.setColor(getBackground());
    g.fillRect(x + 1, 1, d.width - 2 - x, d.height - 2);
  
public voidsetLevel(int level)

    mLevel = (level > mMaximum) ? mMaximum : level;
    repaint();
  
public voidsetMaximum(int max)

    mMaximum = max;
    repaint();
  
public voidupdate(java.awt.Graphics g)

 paint(g);