home *** CD-ROM | disk | FTP | other *** search
/ Learn Java Now / Learn_Java_Now_Microsoft_1996.iso / JavaNow / Code / AppB / NervousText / NervousText.class (.txt) next >
Encoding:
Java Class File  |  1996-07-09  |  2.3 KB  |  76 lines

  1. import java.applet.Applet;
  2. import java.awt.Component;
  3. import java.awt.Event;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6.  
  7. public class NervousText extends Applet implements Runnable {
  8.    char[] separated;
  9.    // $FF: renamed from: s java.lang.String
  10.    String field_0;
  11.    Thread killme;
  12.    // $FF: renamed from: i int
  13.    int field_1;
  14.    int x_coord;
  15.    int y_coord;
  16.    String num;
  17.    int speed = 35;
  18.    int counter;
  19.    boolean threadSuspended;
  20.  
  21.    public void start() {
  22.       if (this.killme == null) {
  23.          this.killme = new Thread(this);
  24.          this.killme.start();
  25.       }
  26.  
  27.    }
  28.  
  29.    public void stop() {
  30.       this.killme = null;
  31.    }
  32.  
  33.    public boolean mouseDown(Event evt, int x, int y) {
  34.       if (this.threadSuspended) {
  35.          this.killme.resume();
  36.       } else {
  37.          this.killme.suspend();
  38.       }
  39.  
  40.       this.threadSuspended = !this.threadSuspended;
  41.       return true;
  42.    }
  43.  
  44.    public void run() {
  45.       for(; this.killme != null; ((Component)this).repaint()) {
  46.          try {
  47.             Thread.sleep(100L);
  48.          } catch (InterruptedException var2) {
  49.          }
  50.       }
  51.  
  52.       this.killme = null;
  53.    }
  54.  
  55.    public void init() {
  56.       this.field_0 = ((Applet)this).getParameter("text");
  57.       if (this.field_0 == null) {
  58.          this.field_0 = "HotJava";
  59.       }
  60.  
  61.       this.separated = new char[this.field_0.length()];
  62.       this.field_0.getChars(0, this.field_0.length(), this.separated, 0);
  63.       ((Applet)this).resize(150, 50);
  64.       ((Component)this).setFont(new Font("TimesRoman", 1, 36));
  65.    }
  66.  
  67.    public void paint(Graphics g) {
  68.       for(this.field_1 = 0; this.field_1 < this.field_0.length(); ++this.field_1) {
  69.          this.x_coord = (int)(Math.random() * (double)10.0F + (double)(15 * this.field_1));
  70.          this.y_coord = (int)(Math.random() * (double)10.0F + (double)36.0F);
  71.          g.drawChars(this.separated, this.field_1, 1, this.x_coord, this.y_coord);
  72.       }
  73.  
  74.    }
  75. }
  76.