public int xCoordToColumnNumber(int x) {
      Insets insets = getInsets();
      if (x < insets.left)
         return -1;
      double colWidth = (double)(getWidth()-insets.left-insets.right) / columns;
      int col = (int)( (x-insets.left) / colWidth);
      if (col >= columns)
         return columns;
      else
         return col;
   }