// File Screensaver.java // // Author: Benjamin Lewis // Date: March 20 1999 // // This program simulates a screensaver. It draws 100 random lines in the // applet window, one at a time, and then clears the window and starts over. // // Bugs: infinite loop in paint method. Multi-threading could improve this. import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; public class Screensaver extends Applet { public static final int NUM_LINES = 100; public static final int PAUSE_MILLISEC = 80; // pause between lines public static final Color BACKGROUND_COLOR = Color.black; public void init() { setBackground(BACKGROUND_COLOR); } public void paint(Graphics g) { int x1, x2, y1, y2; // line coordinates Color lineColor; int height = getSize().height; int width = getSize().width; while (true) { // clear screen g.clearRect(0, 0, width, height); for (int i=0; i