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

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Image;
  7.  
  8. public class Dizzer extends Applet implements Runnable {
  9.    Thread runner;
  10.    String text;
  11.    String FontFace;
  12.    int Size;
  13.    Image OffscreenImage;
  14.    Graphics OffscreenGraphics;
  15.  
  16.    public void init() {
  17.       this.FontFace = ((Applet)this).getParameter("FontFace");
  18.       this.FontFace = this.FontFace == null ? "TimesRoman" : this.FontFace;
  19.       if (((Applet)this).getParameter("Size") == null) {
  20.          this.Size = 26;
  21.       } else {
  22.          this.Size = Integer.parseInt(((Applet)this).getParameter("Size"));
  23.       }
  24.  
  25.       this.text = ((Applet)this).getParameter("Text");
  26.       this.text = this.text == null ? "Dizzer 1.1 (supplied with Lorenz Graf's HTMLtool)" : this.text;
  27.       this.OffscreenImage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
  28.       this.OffscreenGraphics = this.OffscreenImage.getGraphics();
  29.    }
  30.  
  31.    public void run() {
  32.       while(true) {
  33.          try {
  34.             Thread.sleep(100L);
  35.          } catch (InterruptedException var1) {
  36.          }
  37.  
  38.          ((Component)this).repaint();
  39.       }
  40.    }
  41.  
  42.    public void update(Graphics var1) {
  43.       this.paint(var1);
  44.    }
  45.  
  46.    public void paint(Graphics var1) {
  47.       Font var2 = new Font(this.FontFace, 1, this.Size);
  48.       this.OffscreenGraphics.setColor(Color.lightGray);
  49.       this.OffscreenGraphics.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
  50.       this.OffscreenGraphics.setColor(Color.red);
  51.       this.OffscreenGraphics.setFont(var2);
  52.       this.OffscreenGraphics.drawString(this.text, (int)(Math.random() * (double)10.0F) + 20, (int)(Math.random() * (double)10.0F) + 20);
  53.       var1.drawImage(this.OffscreenImage, 0, 0, this);
  54.    }
  55.  
  56.    public void stop() {
  57.       if (this.runner != null) {
  58.          this.runner.stop();
  59.          this.runner = null;
  60.       }
  61.  
  62.    }
  63.  
  64.    public void start() {
  65.       if (this.runner == null) {
  66.          this.runner = new Thread(this);
  67.          this.runner.start();
  68.       }
  69.  
  70.    }
  71.  
  72.    public String getAppletInfo() {
  73.       return "Dizzer v1.1 copyright 1997 by Lorenz Graf";
  74.    }
  75. }
  76.