import java.awt.*; /** Program: EssentialRunner application Purpose: simple demonstration of a runnable applet @author john@december.com @version 1.61; 21 Nov 95 Note: working on conversion to beta 1.00 */ public class EssentialRunner extends java.applet.Applet implements Runnable { private Thread flow; boolean done, pause; int sizewidth = 400; int interval = 10; int x, y, cycle; public void init() { resize(sizewidth, sizewidth); } public void start() { done = false; pause = false; x = 0; y = 0; cycle = 0; flow = new Thread(this); flow.start(); } public void run() { try { while (!done) { Thread.sleep(interval); if (!pause) repaint(); } } catch (InterruptedException e){}; } public void update(Graphics context) { context.setColor(Color.green); context.drawLine(sizewidth/2, sizewidth/2, x, y); y = y + interval; if (y > sizewidth) { y = 0; cycle++; if ((cycle%2) == 0) x = cycle*interval; else x = sizewidth - cycle*interval; } } public boolean mouseDown(java.awt.Event evt, int x, int y) { pause = !pause; return (true); } public void stop() { done = true; flow.stop(); } }