home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 1998 October / PCpro_1998_10.ISO / internet / layout / htmltool.exe / _SETUP.1 / MarqueeForImages.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-05-04  |  2.6 KB  |  79 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Graphics;
  5. import java.awt.Image;
  6.  
  7. public class MarqueeForImages extends Applet implements Runnable {
  8.    Thread runner;
  9.    String text;
  10.    String ImageSrc;
  11.    int step;
  12.    // $FF: renamed from: x int
  13.    int field_0;
  14.    Image OffscreenImage;
  15.    Image Img;
  16.    Graphics OffscreenGraphics;
  17.  
  18.    public void init() {
  19.       this.ImageSrc = ((Applet)this).getParameter("ImageSrc");
  20.       this.ImageSrc = this.ImageSrc == null ? "HTMLtool.gif" : this.ImageSrc;
  21.       if (((Applet)this).getParameter("Step") == null) {
  22.          this.step = 1;
  23.       } else {
  24.          this.step = Integer.parseInt(((Applet)this).getParameter("step"));
  25.       }
  26.  
  27.       this.field_0 = ((Component)this).size().width;
  28.       this.OffscreenImage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
  29.       this.OffscreenGraphics = this.OffscreenImage.getGraphics();
  30.       this.Img = ((Applet)this).getImage(((Applet)this).getCodeBase(), this.ImageSrc);
  31.    }
  32.  
  33.    public void run() {
  34.       while(true) {
  35.          try {
  36.             Thread.sleep(10L);
  37.             this.field_0 -= this.step;
  38.             ((Component)this).repaint();
  39.          } catch (InterruptedException var1) {
  40.          }
  41.       }
  42.    }
  43.  
  44.    public void update(Graphics g) {
  45.       this.paint(g);
  46.    }
  47.  
  48.    public void paint(Graphics g) {
  49.       if (this.field_0 < -this.Img.getWidth(this)) {
  50.          this.field_0 = ((Component)this).size().width;
  51.       }
  52.  
  53.       this.OffscreenGraphics.setColor(Color.lightGray);
  54.       this.OffscreenGraphics.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
  55.       this.OffscreenGraphics.drawImage(this.Img, this.field_0, 0, this);
  56.       g.drawImage(this.OffscreenImage, 0, 0, this);
  57.    }
  58.  
  59.    public void stop() {
  60.       if (this.runner != null) {
  61.          this.runner.stop();
  62.          this.runner = null;
  63.       }
  64.  
  65.    }
  66.  
  67.    public void start() {
  68.       if (this.runner == null) {
  69.          this.runner = new Thread(this);
  70.          this.runner.start();
  71.       }
  72.  
  73.    }
  74.  
  75.    public String getAppletInfo() {
  76.       return "Marquee for Images v1.1 copyright 1997 by Lorenz Graf";
  77.    }
  78. }
  79.