home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / Timer.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  3.5 KB  |  153 lines

  1. package javax.swing;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.io.Serializable;
  6. import java.util.EventListener;
  7. import javax.swing.event.EventListenerList;
  8.  
  9. public class Timer implements Serializable {
  10.    protected EventListenerList listenerList = new EventListenerList();
  11.    boolean eventQueued = false;
  12.    int initialDelay;
  13.    int delay;
  14.    boolean repeats = true;
  15.    boolean coalesce = true;
  16.    Runnable doPostEvent = null;
  17.    private static boolean logTimers;
  18.    long expirationTime;
  19.    Timer nextTimer;
  20.    boolean running;
  21.    // $FF: synthetic field
  22.    static Class class$java$awt$event$ActionListener;
  23.  
  24.    public Timer(int var1, ActionListener var2) {
  25.       this.delay = var1;
  26.       this.initialDelay = var1;
  27.       this.doPostEvent = new DoPostEvent(this);
  28.       if (var2 != null) {
  29.          this.addActionListener(var2);
  30.       }
  31.  
  32.    }
  33.  
  34.    public void addActionListener(ActionListener var1) {
  35.       this.listenerList.add(class$java$awt$event$ActionListener == null ? (class$java$awt$event$ActionListener = class$("java.awt.event.ActionListener")) : class$java$awt$event$ActionListener, var1);
  36.    }
  37.  
  38.    public void removeActionListener(ActionListener var1) {
  39.       this.listenerList.remove(class$java$awt$event$ActionListener == null ? (class$java$awt$event$ActionListener = class$("java.awt.event.ActionListener")) : class$java$awt$event$ActionListener, var1);
  40.    }
  41.  
  42.    protected void fireActionPerformed(ActionEvent var1) {
  43.       Object[] var2 = this.listenerList.getListenerList();
  44.  
  45.       for(int var3 = var2.length - 2; var3 >= 0; var3 -= 2) {
  46.          if (var2[var3] == (class$java$awt$event$ActionListener == null ? (class$java$awt$event$ActionListener = class$("java.awt.event.ActionListener")) : class$java$awt$event$ActionListener)) {
  47.             ((ActionListener)var2[var3 + 1]).actionPerformed(var1);
  48.          }
  49.       }
  50.  
  51.    }
  52.  
  53.    public EventListener[] getListeners(Class var1) {
  54.       return this.listenerList.getListeners(var1);
  55.    }
  56.  
  57.    TimerQueue timerQueue() {
  58.       return TimerQueue.sharedInstance();
  59.    }
  60.  
  61.    public static void setLogTimers(boolean var0) {
  62.       logTimers = var0;
  63.    }
  64.  
  65.    public static boolean getLogTimers() {
  66.       return logTimers;
  67.    }
  68.  
  69.    public void setDelay(int var1) {
  70.       if (var1 < 0) {
  71.          throw new IllegalArgumentException("Invalid delay: " + var1);
  72.       } else {
  73.          this.delay = var1;
  74.       }
  75.    }
  76.  
  77.    public int getDelay() {
  78.       return this.delay;
  79.    }
  80.  
  81.    public void setInitialDelay(int var1) {
  82.       if (var1 < 0) {
  83.          throw new IllegalArgumentException("Invalid initial delay: " + var1);
  84.       } else {
  85.          this.initialDelay = var1;
  86.       }
  87.    }
  88.  
  89.    public int getInitialDelay() {
  90.       return this.initialDelay;
  91.    }
  92.  
  93.    public void setRepeats(boolean var1) {
  94.       this.repeats = var1;
  95.    }
  96.  
  97.    public boolean isRepeats() {
  98.       return this.repeats;
  99.    }
  100.  
  101.    public void setCoalesce(boolean var1) {
  102.       this.coalesce = var1;
  103.    }
  104.  
  105.    public boolean isCoalesce() {
  106.       return this.coalesce;
  107.    }
  108.  
  109.    public void start() {
  110.       this.timerQueue().addTimer(this, System.currentTimeMillis() + (long)this.getInitialDelay());
  111.    }
  112.  
  113.    public boolean isRunning() {
  114.       return this.timerQueue().containsTimer(this);
  115.    }
  116.  
  117.    public void stop() {
  118.       this.timerQueue().removeTimer(this);
  119.       this.cancelEvent();
  120.    }
  121.  
  122.    public void restart() {
  123.       this.stop();
  124.       this.start();
  125.    }
  126.  
  127.    synchronized void cancelEvent() {
  128.       this.eventQueued = false;
  129.    }
  130.  
  131.    synchronized void post() {
  132.       if (!this.eventQueued) {
  133.          this.eventQueued = true;
  134.          SwingUtilities.invokeLater(this.doPostEvent);
  135.       }
  136.  
  137.    }
  138.  
  139.    // $FF: synthetic method
  140.    static boolean access$000() {
  141.       return logTimers;
  142.    }
  143.  
  144.    // $FF: synthetic method
  145.    static Class class$(String var0) {
  146.       try {
  147.          return Class.forName(var0);
  148.       } catch (ClassNotFoundException var2) {
  149.          throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  150.       }
  151.    }
  152. }
  153.