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 / Spinner.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-06-23  |  1.7 KB  |  64 lines

  1. package actual;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import java.awt.Graphics;
  6.  
  7. public class Spinner extends Component {
  8.    float percentDone;
  9.    int totalTicks = 60;
  10.    int currentTick;
  11.    SpinnerThread spinnerThread;
  12.  
  13.    public Spinner() {
  14.       ((Component)this).setForeground(Color.gray);
  15.       ((Component)this).setForeground(Color.lightGray);
  16.    }
  17.  
  18.    public void paint(Graphics var1) {
  19.       byte var2 = 90;
  20.       int var3 = (int)(this.percentDone * 360.0F);
  21.       var1.setColor(((Component)this).getBackground());
  22.       var1.fillArc(3, 3, ((Component)this).getSize().width - 8, ((Component)this).getSize().height - 8, 0, 360);
  23.       var1.setColor(((Component)this).getForeground());
  24.       var1.fillArc(3, 3, ((Component)this).getSize().width - 8, ((Component)this).getSize().height - 8, var2, var3);
  25.       var1.setColor(Color.black);
  26.       var1.drawArc(3, 3, ((Component)this).getSize().width - 8, ((Component)this).getSize().height - 8, 0, 360);
  27.    }
  28.  
  29.    public void setCurrentTick(int var1) {
  30.       this.currentTick = var1;
  31.       if (this.currentTick > this.totalTicks) {
  32.          this.percentDone = 1.0F;
  33.       } else if (this.currentTick == 0) {
  34.          this.percentDone = 0.0F;
  35.       } else {
  36.          this.percentDone = (float)this.currentTick / (float)this.totalTicks;
  37.       }
  38.  
  39.       ((Component)this).repaint();
  40.    }
  41.  
  42.    public void startSpinning() {
  43.       this.spinnerThread = new SpinnerThread(this);
  44.       this.spinnerThread.start();
  45.    }
  46.  
  47.    public void stopSpinning() {
  48.       this.spinnerThread.stop();
  49.       this.spinnerThread = null;
  50.    }
  51.  
  52.    public void setTotalTicks(int var1) {
  53.       this.totalTicks = var1;
  54.    }
  55.  
  56.    public int getTotalTicks() {
  57.       return this.totalTicks;
  58.    }
  59.  
  60.    public int getCurrentTick() {
  61.       return this.currentTick;
  62.    }
  63. }
  64.