1  /*
  2   *  File:  ColorBoxes.java
  3   *
  4   *  Drawing simple shapes, especially rectangles and ovals
  5   *
  6   *  Copyright:  Northeast Parallel Architectures Center
  7   */
  8  
  9  import java.awt.Color;
 10  import java.awt.Graphics;
 11  
 12  public class ColorBoxes extends java.applet.Applet {
 13  
 14    public void paint(Graphics g) {
 15      int rval, gval, bval;
 16  
 17      // getSize() method is new in Java 1.1:
 18      for (int j = 30; j < (getSize().height - 25); j += 30) {
 19        for (int i = 5; i < (getSize().width - 25); i += 30) {
 20          rval = (int)Math.floor(Math.random() * 256);
 21          gval = (int)Math.floor(Math.random() * 256);
 22          bval = (int)Math.floor(Math.random() * 256);
 23          
 24          g.setColor(new Color(rval,gval,bval));
 25          g.fillRect(i,j,25,25);
 26          g.setColor(Color.black);
 27          g.drawRect(i,j,25,25);
 28        }
 29      }
 30    }
 31    
 32  }