public void paintComponent(Graphics g) {
      super.paintComponent(g);
      if ( (OSI == null) || OSI.getWidth() != getWidth() || OSI.getHeight() != getHeight() ) {
         OSI = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
         needsRedraw = true;
      }
      if (needsRedraw) {
         Graphics OSG = OSI.getGraphics();
         for (int r = 0; r < rows; r++)
            for (int c = 0; c < columns; c++)
               drawSquare(OSG,r,c,false);
         OSG.dispose();
         needsRedraw = false;
      }
      g.drawImage(OSI,0,0,null);
   }