home *** CD-ROM | disk | FTP | other *** search
/ Datatid 2000 #1 / Datatid-2000-01.iso / Internet / SPLASH / SPLASH12.EXE / data1.cab / Plugins / Digi_Clock / WebClock.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-12-18  |  1.9 KB  |  63 lines

  1. import java.applet.Applet;
  2. import java.awt.Container;
  3. import java.awt.Font;
  4. import java.awt.Label;
  5. import java.text.DateFormat;
  6. import java.util.Date;
  7. import java.util.TimeZone;
  8.  
  9. public class WebClock extends Applet implements Runnable {
  10.    private Label clock_label;
  11.    private Thread tick_thread;
  12.  
  13.    public void init() {
  14.       this.updateDateTime();
  15.    }
  16.  
  17.    private void updateDateTime() {
  18.       Date var1 = new Date();
  19.       DateFormat var2 = DateFormat.getDateTimeInstance(0, 3);
  20.       TimeZone var3 = TimeZone.getDefault();
  21.       var2.setTimeZone(var3);
  22.       String var4 = var2.format(var1);
  23.       if (this.clock_label == null) {
  24.          this.clock_label = new Label(var4, 1);
  25.          this.clock_label.setFont(new Font("TimesRoman", 0, 24));
  26.          ((Container)this).add(this.clock_label);
  27.       } else {
  28.          this.clock_label.setText(var4);
  29.       }
  30.    }
  31.  
  32.    public void start() {
  33.       if (this.tick_thread == null) {
  34.          this.tick_thread = new Thread(this);
  35.          this.tick_thread.start();
  36.       }
  37.  
  38.    }
  39.  
  40.    public void stop() {
  41.       this.tick_thread = null;
  42.    }
  43.  
  44.    public void run() {
  45.       Thread var1 = Thread.currentThread();
  46.       var1.setPriority(1);
  47.  
  48.       while(var1 == this.tick_thread) {
  49.          this.updateDateTime();
  50.  
  51.          try {
  52.             Thread.sleep(60000L);
  53.          } catch (InterruptedException var2) {
  54.          }
  55.       }
  56.  
  57.    }
  58.  
  59.    public String getAppletInfo() {
  60.       return Variables.program + " " + Variables.version + " " + Variables.copyright + " " + Variables.right;
  61.    }
  62. }
  63.