home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1998 September / maximum-cd-1998-09.iso / Hotmetal / hm4ev.exe / applets.z / NervousText.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-08-19  |  2.1 KB  |  96 lines

  1. package symantec.itools.multimedia;
  2.  
  3. import java.awt.Canvas;
  4. import java.awt.Component;
  5. import java.awt.Dimension;
  6. import java.awt.Graphics;
  7.  
  8. public class NervousText extends Canvas implements Runnable {
  9.    char[] separated;
  10.    String text;
  11.    boolean paused = false;
  12.    Thread jitter;
  13.  
  14.    public NervousText() {
  15.       this.setText("text");
  16.    }
  17.  
  18.    public void addNotify() {
  19.       super.addNotify();
  20.       this.jitter = new Thread(this);
  21.       this.jitter.start();
  22.    }
  23.  
  24.    public synchronized void removeNotify() {
  25.       if (this.jitter != null) {
  26.          this.jitter.stop();
  27.          this.jitter = null;
  28.       }
  29.  
  30.       super.removeNotify();
  31.    }
  32.  
  33.    public synchronized void show() {
  34.       super.show();
  35.       if (((Component)this).isVisible() && this.jitter != null) {
  36.          this.jitter.resume();
  37.       }
  38.  
  39.    }
  40.  
  41.    public synchronized void hide() {
  42.       super.hide();
  43.       if (!((Component)this).isVisible() && this.jitter != null) {
  44.          this.jitter.suspend();
  45.       }
  46.  
  47.    }
  48.  
  49.    public void setText(String var1) {
  50.       this.text = var1;
  51.       this.separated = new char[this.text.length()];
  52.       this.text.getChars(0, this.text.length(), this.separated, 0);
  53.    }
  54.  
  55.    public String getText() {
  56.       return this.text;
  57.    }
  58.  
  59.    public void run() {
  60.       while(true) {
  61.          if (!this.paused) {
  62.             try {
  63.                Thread.sleep(150L);
  64.             } catch (Exception var1) {
  65.             }
  66.  
  67.             ((Component)this).repaint();
  68.          }
  69.       }
  70.    }
  71.  
  72.    public void pause(boolean var1) {
  73.       this.paused = var1;
  74.    }
  75.  
  76.    public boolean isPaused() {
  77.       return this.paused;
  78.    }
  79.  
  80.    public void setPaused(boolean var1) {
  81.       this.paused = var1;
  82.    }
  83.  
  84.    public void paint(Graphics var1) {
  85.       Dimension var2 = ((Component)this).size();
  86.       var1.clipRect(0, 0, var2.width, var2.height);
  87.  
  88.       for(int var3 = 0; var3 < this.text.length(); ++var3) {
  89.          int var4 = (int)(Math.random() * (double)10.0F + (double)(20 * var3));
  90.          int var5 = (int)(Math.random() * (double)10.0F + (double)36.0F);
  91.          var1.drawChars(this.separated, var3, 1, var4, var5);
  92.       }
  93.  
  94.    }
  95. }
  96.