2005-08-11  Lillian Angel  <[EMAIL PROTECTED]>

        * javax/swing/JTable
        (rowAtPoint): Added in a check for null. Was getting NPE.
        (columnAtPoint): Likewise.

Index: javax/swing/JTable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v
retrieving revision 1.41
diff -u -r1.41 JTable.java
--- javax/swing/JTable.java	9 Aug 2005 19:46:55 -0000	1.41
+++ javax/swing/JTable.java	11 Aug 2005 20:18:07 -0000
@@ -910,20 +910,23 @@
    */
   public int columnAtPoint(Point point)
   {
-    int x0 = getLocation().x;
-    int ncols = getColumnCount();
-    Dimension gap = getIntercellSpacing();
-    TableColumnModel cols = getColumnModel();
-    int x = point.x;
-    
-    for (int i = 0; i < ncols; ++i)
+    if (point != null)
       {
-        int width = cols.getColumn(i).getWidth() + (gap == null ? 0 : gap.width);
-        if (0 <= x && x < width)
-          return i;
-        x -= width;  
+        int x0 = getLocation().x;
+        int ncols = getColumnCount();
+        Dimension gap = getIntercellSpacing();
+        TableColumnModel cols = getColumnModel();
+        int x = point.x;
+
+        for (int i = 0; i < ncols; ++i)
+          {
+            int width = cols.getColumn(i).getWidth()
+                        + (gap == null ? 0 : gap.width);
+            if (0 <= x && x < width)
+              return i;
+            x -= width;
+          }
       }
-    
     return -1;
   }
 
@@ -937,19 +940,21 @@
    */
   public int rowAtPoint(Point point)
   {
-    int y0 = getLocation().y;
-    int nrows = getRowCount();
-    Dimension gap = getIntercellSpacing();
-    int height = getRowHeight() + (gap == null ? 0 : gap.height);
-    int y = point.y;
-    
-    for (int i = 0; i < nrows; ++i)
+    if (point != null)
       {
-        if (0 <= y && y < height)
-          return i;
-        y -= height;
+        int y0 = getLocation().y;
+        int nrows = getRowCount();
+        Dimension gap = getIntercellSpacing();
+        int height = getRowHeight() + (gap == null ? 0 : gap.height);
+        int y = point.y;
+
+        for (int i = 0; i < nrows; ++i)
+          {
+            if (0 <= y && y < height)
+              return i;
+            y -= height;
+          }
       }
-      
     return -1;
   }
 
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to