code: public void paint(final Graphics g) {
          // Draw grid on background image, which is faster
          final int numberOfColumns = this.cellGrid.getNumberOfColumns();
          final int numberOfRows = this.cellGrid.getNumberOfRows();
          if ( this.backgroundImage == null ) {
              final Dimension d = getSize();
              this.backgroundImage = createImage( d.width,
                                             d.height );
              final Graphics backgroundImageGraphics = this.backgroundImage.getGraphics();
              // draw background (MSIE doesn't do that)
              backgroundImageGraphics.setColor( getBackground() );
              backgroundImageGraphics.fillRect( 0,
                                                0,
                                                d.width,
                                                d.height );
              backgroundImageGraphics.setColor( CellGridCanvas.BACKGROUND_COLOR );
              backgroundImageGraphics.fillRect( 0,
                                                0,
                                                this.cellSize * numberOfColumns - 1,
                                                this.cellSize * numberOfRows - 1 );
              backgroundImageGraphics.setColor( CellGridCanvas.GRID_COLOR );
              for ( int x = 1; x < numberOfColumns; x++ ) {
                  backgroundImageGraphics.drawLine( x * this.cellSize - 1,
                                                    0,
                                                    x * this.cellSize - 1,
                                                    this.cellSize * numberOfRows - 1 );
              }
              for ( int y = 1; y < numberOfRows; y++ ) {
                  backgroundImageGraphics.drawLine( 0,
                                                    y * this.cellSize - 1,
                                                    this.cellSize * numberOfColumns - 1,
                                                    y * this.cellSize - 1 );
              }
          }
          g.drawImage( this.backgroundImage,
                       0,
                       0,
                       null );
  
          // draw populated cells
          for ( int row = 0; row < numberOfRows; row++ ) {
              for ( int column = 0; column < numberOfColumns; column++ ) {
                  final Cell cell = this.cellGrid.getCellAt( row,
                                                  column );
                  if ( cell.getCellState() == CellState.LIVE ) {
                      g.drawImage( this.liveCellImage,
                                   column * this.cellSize,
                                   row * this.cellSize,
                                   this );
                  }
              }
          }
      }
docs: Draw this generation.
  
  @see java.awt.Component#paint(java.awt.Graphics)