1  /*
  2   *  File:  SquareTest.java
  3   *
  4   *  Draw a square
  5   *
  6   *  Copyright:  Northeast Parallel Architectures Center
  7   *  
  8   */
  9  
 10  import java.applet.Applet;
 11  import java.awt.Graphics;
 12  
 13  public class SquareTest extends Applet {
 14  
 15     // create a reference to a square:
 16     private Square square;
 17     
 18     // square parameters:
 19     private int x, y, length = 20;      
 20     
 21     public void paint( Graphics g ) {
 22  
 23        // draw an 8x8 checkerboard:
 24        y = 0;
 25        for ( int i = 0; i < 8; i++ ) {
 26           x = 0; y += length;
 27           for ( int j = 0; j < 8; j++ ) {
 28              x += length;
 29              square = new Square( x, y, length );
 30              if ( (i + j) % 2 == 0 ) {
 31                 square.draw( g );
 32              } else {
 33                 square.fill( g );
 34              }
 35           }
 36        }
 37  
 38     }
 39     
 40  }