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      for (int j = 30; j < (size().height - 25); j += 30) {
 18        for (int i = 5; i < (size().width - 25); i += 30) {
 19          rval = (int)Math.floor(Math.random() * 256);
 20          gval = (int)Math.floor(Math.random() * 256);
 21          bval = (int)Math.floor(Math.random() * 256);
 22          
 23          g.setColor(new Color(rval,gval,bval));
 24          g.fillRect(i,j,25,25);
 25          g.setColor(Color.black);
 26          g.drawRect(i,j,25,25);
 27        }
 28      }
 29    }
 30    
 31  }