public int yCoordToRowNumber(int y) {
      Insets insets = getInsets();
      if (y < insets.top)
         return -1;
      double rowHeight = (double)(getHeight()-insets.top-insets.bottom) / rows;
      int row = (int)( (y-insets.top) / rowHeight);
      if (row >= rows)
         return rows;
      else
         return row;
   }