FileDocCategorySizeDatePackage
ProgressBar.javaAPI DocJMF 2.1.1e2147Mon May 12 12:20:30 BST 2003jmapps.ui

ProgressBar

public class ProgressBar extends Canvas

Fields Summary
private int
nMinPos
private int
nMaxPos
private int
nCurPos
Constructors Summary
public ProgressBar(int nMin, int nMax)

        super ();

        nMinPos = nMin;
        nMaxPos = nMax;
        if ( nMaxPos <= nMinPos )
            nMaxPos = nMinPos + 1;
        nCurPos = nMinPos;
        this.setBackground ( Color.lightGray );
    
Methods Summary
public intgetCurPercent()

        return ( 100 * (nCurPos - nMinPos) / (nMaxPos - nMinPos) );
    
public intgetCurPos()

        return ( nCurPos );
    
public intgetMaxPos()

        return ( nMaxPos );
    
public intgetMinPos()

        return ( nMinPos );
    
public java.awt.DimensiongetPreferredSize()

        Dimension    dim;

        dim = new Dimension ( 128, 22 );
        return ( dim );
    
public voidpaint(java.awt.Graphics graphics)

        Rectangle    rect;

        rect = this.getBounds ();
        rect.x = 0;
        rect.y = 0;

        graphics.setColor ( Color.darkGray );
        graphics.drawLine ( rect.x, rect.y, rect.x, rect.y + rect.height - 2 );
        graphics.drawLine ( rect.x, rect.y, rect.x + rect.width - 2, rect.y );

        graphics.setColor ( Color.white );
        graphics.drawLine ( rect.x + rect.width - 1, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + 1 );
        graphics.drawLine ( rect.x + rect.width - 1, rect.y + rect.height - 1, rect.x + 1, rect.y + rect.height - 1 );

        rect.x++;
        rect.y++;
        rect.width -= 2;
        rect.height -= 2;

        graphics.setColor ( Color.blue );
        rect.width = rect.width * (nCurPos - nMinPos) / (nMaxPos - nMinPos);
        graphics.fillRect ( rect.x, rect.y, rect.width, rect.height );
    
public voidsetCurPos(int nPos)

        nCurPos = nPos;
        if ( nCurPos > nMaxPos )
            nCurPos = nMaxPos;
        if ( nCurPos < nMinPos )
            nCurPos = nMinPos;
        repaint ();