1  /*
  2   *  File:  ColorBoxes.java
  3   *
  4   *  Display pre-defined colors
  5   *
  6   *  Copyright:  Northeast Parallel Architectures Center
  7   *  
  8   */
  9  
 10  import java.applet.Applet;
 11  import java.awt.Graphics;
 12  import java.awt.Color;
 13  
 14  public class ColorBoxes extends Applet {
 15  
 16     public void paint( Graphics g ) {
 17        
 18        // Draw the first row of color boxes:
 19        g.setColor( Color.black );
 20        g.fillRect( 10, 10, 50, 50 );
 21        g.setColor( Color.blue );
 22        g.fillRect( 80, 10, 50, 50 );
 23        g.setColor( Color.cyan );
 24        g.fillRect( 150, 10, 50, 50 );
 25        g.setColor( Color.darkGray );
 26        g.fillRect( 220, 10, 50, 50 );
 27        
 28        // Draw the second row of color boxes:
 29        g.setColor( Color.gray );
 30        g.fillRect( 10, 80, 50, 50 );
 31        g.setColor( Color.green );
 32        g.fillRect( 80, 80, 50, 50 );
 33        g.setColor( Color.lightGray );
 34        g.fillRect( 150, 80, 50, 50 );
 35        g.setColor( Color.magenta );
 36        g.fillRect( 220, 80, 50, 50 );
 37        
 38        // Draw the third row of color boxes:
 39        g.setColor( Color.orange );
 40        g.fillRect( 10, 150, 50, 50 );
 41        g.setColor( Color.pink );
 42        g.fillRect( 80, 150, 50, 50 );
 43        g.setColor( Color.red );
 44        g.fillRect( 150, 150, 50, 50 );
 45        g.setColor( Color.white );
 46        g.fillRect( 220, 150, 50, 50 );
 47        
 48        // Draw the fourth row of color boxes:
 49        g.setColor( Color.yellow );
 50        g.fillRect( 10, 220, 50, 50 );
 51        
 52     }
 53     
 54  }