FileDocCategorySizeDatePackage
ColorBoxes.javaAPI DocExample4067Mon Apr 06 18:10:22 BST 1998None

CBox

public class CBox extends Canvas implements Runnable

Fields Summary
private Thread
t
private int
pause
private static final Color[]
colors
private Color
cColor
Constructors Summary
public CBox(int pause)

    this.pause = pause;
    t = new Thread(this);
    t.start(); 
  
Methods Summary
private static final java.awt.ColornewColor()

       
    return colors[
      (int)(Math.random() * colors.length)
    ];
  
public voidpaint(java.awt.Graphics g)

    g.setColor(cColor);
    Dimension s = getSize();
    g.fillRect(0, 0, s.width, s.height);
  
public voidrun()

    while(true) {
      cColor = newColor();
      repaint();
      try {
        t.sleep(pause);
      } catch(InterruptedException e) {}
    }