// Processed by NMI's Java Code Viewer 4.8.2 © 1997-2000 B. Lemaire // Website: http://njcv.htmlplanet.com E-mail: info@njcv.htmlplanet.com // Copy registered to Evaluation Copy // Source File Name: Timer.java import java.awt.Component; import java.awt.Event; public class Timer implements Runnable { Component target; int eventType; boolean repeat; boolean repeating; boolean execute; Thread thread; int delay; public Timer(Component component, int i, boolean flag, int j) { this(component, i, flag, j, 10); } public Timer(Component component, int i, boolean flag, int j, int k) { target = component; delay = i; repeat = flag; execute = false; thread = new Thread(this); eventType = j; thread.setPriority(k); thread.start(); } public void setEventType(int i) { eventType = i; } public int getEventType() { return eventType; } public void setTarget(Component component) { target = component; } public Component getTarget() { return target; } public void setDelay(int i) { delay = i; } public int getDelay() { return delay; } public void start() { execute = true; thread.resume(); } public void setRepeat(boolean flag) { repeat = flag; } public boolean getRepeat() { return repeat; } public void start(int i) { delay = i; start(); } public void start(boolean flag) { repeat = flag; start(); } public void start(int i, boolean flag) { delay = i; repeat = flag; start(); } public void stop() { execute = false; repeating = false; } public void run() { if(!execute) thread.suspend(); do try { repeating = repeat; do { Thread.sleep(delay); if(execute) target.handleEvent(new Event(this, eventType, null)); } while(repeating); thread.suspend(); } catch(InterruptedException _ex) { return; } while(true); } }