FileDocCategorySizeDatePackage
Gauge.javaAPI DocExample1686Wed Apr 19 11:21:46 BST 2000actual

Gauge

public class Gauge extends Component

Fields Summary
int
current
int
total
int
Height
int
Width
Constructors Summary
public Gauge()
Constructs a Gauge

  // arbitrary 

        
    
      this(Color.lightGray);
  
public Gauge(Color gaugeColor)
Constructs a that will be drawn uses the specified color.

gaugeColor
the color of this Gauge

      setBackground(gaugeColor);
  
Methods Summary
public intgetCurrentAmount()

      return current;
  
public java.awt.DimensiongetMinimumSize()

      return new Dimension(Width, Height);
  
public java.awt.DimensiongetPreferredSize()

      return new Dimension(Width, Height);
  
public intgetTotalAmount()

      return total;
  
public voidpaint(java.awt.Graphics g)

      int barWidth = (int) (((float)current/(float)total) * getSize().width);
      g.setColor(getBackground());
      g.fill3DRect(0, 0, barWidth, getSize().height-2, true);
  
public voidsetCurrentAmount(int Amount)

      current = Amount; 

      // make sure we don't go over total
      if(current > 100)
       current = 100;

      repaint();