home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Documents / JAVA Programming / examples / 18 / ObservedImageLoad.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-09-08  |  2.1 KB  |  63 lines

  1. import java.applet.Applet;
  2. import java.awt.Component;
  3. import java.awt.Dimension;
  4. import java.awt.Graphics;
  5. import java.awt.Image;
  6. import java.awt.image.ImageObserver;
  7.  
  8. public class ObservedImageLoad extends Applet implements Runnable, ImageObserver {
  9.    Image art;
  10.    // $FF: renamed from: d java.awt.Dimension
  11.    Dimension field_0;
  12.    int progress;
  13.    Thread motor;
  14.    boolean loaded;
  15.  
  16.    public void init() {
  17.       this.art = ((Applet)this).getImage(((Applet)this).getDocumentBase(), ((Applet)this).getParameter("img"));
  18.       this.loaded = false;
  19.       this.progress = 0;
  20.    }
  21.  
  22.    public void paint(Graphics var1) {
  23.       this.field_0 = ((Component)this).getSize();
  24.       this.loaded = var1.drawImage(this.art, 0, 0, this);
  25.    }
  26.  
  27.    public boolean imageUpdate(Image var1, int var2, int var3, int var4, int var5, int var6) {
  28.       if ((var2 & 32) != 1) {
  29.          if (this.progress < this.field_0.height) {
  30.             this.progress += var6;
  31.          }
  32.  
  33.          System.out.println(this.progress + "/" + this.field_0.height);
  34.          return true;
  35.       } else {
  36.          return false;
  37.       }
  38.    }
  39.  
  40.    public void start() {
  41.       this.motor = new Thread(this);
  42.       this.motor.start();
  43.    }
  44.  
  45.    public void stop() {
  46.       this.motor.stop();
  47.    }
  48.  
  49.    public void run() {
  50.       this.motor.setPriority(1);
  51.  
  52.       while(!this.loaded) {
  53.          ((Component)this).repaint();
  54.  
  55.          try {
  56.             Thread.sleep(200L);
  57.          } catch (InterruptedException var1) {
  58.          }
  59.       }
  60.  
  61.    }
  62. }
  63.