home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / WDESAMPL.BIN / Gauge.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-06-23  |  1.3 KB  |  56 lines

  1. package actual;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import java.awt.Dimension;
  6. import java.awt.Graphics;
  7.  
  8. public class Gauge extends Component {
  9.    int current;
  10.    int total;
  11.    int Height;
  12.    int Width;
  13.  
  14.    public Gauge() {
  15.       this(Color.lightGray);
  16.    }
  17.  
  18.    public Gauge(Color var1) {
  19.       this.total = 100;
  20.       this.Height = 18;
  21.       this.Width = 250;
  22.       ((Component)this).setBackground(var1);
  23.    }
  24.  
  25.    public void paint(Graphics var1) {
  26.       int var2 = (int)((float)this.current / (float)this.total * (float)((Component)this).getSize().width);
  27.       var1.setColor(((Component)this).getBackground());
  28.       var1.fill3DRect(0, 0, var2, ((Component)this).getSize().height - 2, true);
  29.    }
  30.  
  31.    public void setCurrentAmount(int var1) {
  32.       this.current = var1;
  33.       if (this.current > 100) {
  34.          this.current = 100;
  35.       }
  36.  
  37.       ((Component)this).repaint();
  38.    }
  39.  
  40.    public int getCurrentAmount() {
  41.       return this.current;
  42.    }
  43.  
  44.    public int getTotalAmount() {
  45.       return this.total;
  46.    }
  47.  
  48.    public Dimension getPreferredSize() {
  49.       return new Dimension(this.Width, this.Height);
  50.    }
  51.  
  52.    public Dimension getMinimumSize() {
  53.       return new Dimension(this.Width, this.Height);
  54.    }
  55. }
  56.