Index: javax/swing/table/DefaultTableModel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/table/DefaultTableModel.java,v
retrieving revision 1.14
diff -u -r1.14 DefaultTableModel.java
--- javax/swing/table/DefaultTableModel.java	15 Feb 2006 21:48:32 -0000	1.14
+++ javax/swing/table/DefaultTableModel.java	8 May 2006 12:21:06 -0000
@@ -1,5 +1,5 @@
 /* DefaultTableModel.java --
-   Copyright (C) 2002, 2004, 2005,  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -294,12 +294,7 @@
     else 
     {
       int rowsToAdd = rowCount - existingRowCount;
-      for (int i = 0; i < rowsToAdd; i++) 
-        {
-          Vector tmp = new Vector();
-          tmp.setSize(columnIdentifiers.size());
-          dataVector.add(tmp);
-        } 
+      addExtraRows(rowsToAdd, columnIdentifiers.size());
       fireTableRowsInserted(existingRowCount,rowCount-1);
     }
   }
@@ -366,12 +361,7 @@
       if (columnData.length > dataVector.size()) 
       {
         int rowsToAdd = columnData.length - dataVector.size();
-        for (int i = 0; i < rowsToAdd; i++) 
-        {
-          Vector tmp = new Vector();
-          tmp.setSize(columnIdentifiers.size());
-          dataVector.add(tmp);
-        }
+	addExtraRows(rowsToAdd, columnIdentifiers.size());
       }
       else if (columnData.length < dataVector.size())
       {
@@ -502,7 +492,9 @@
     else 
     {
       if (column < getColumnCount())
-      {  
+      {
+	checkSize();
+
         Object id = columnIdentifiers.get(column);
         if (id != null) 
           result = id.toString();
@@ -516,6 +508,41 @@
   }
 
   /**
+   * Checks the real columns/rows sizes against the ones returned by
+   * <code>getColumnCount()</code> and <code>getRowCount()</code>.
+   * If the supposed one are bigger, then we grow <code>columIdentifiers</code>
+   * and <code>dataVector</code> to their expected size.
+   */
+  private void checkSize() {
+    int columnCount = getColumnCount();
+    int rowCount = getRowCount();
+
+    if (columnCount > columnIdentifiers.size())
+      columnIdentifiers.setSize(columnCount);
+	    
+    if (rowCount > dataVector.size())
+      {
+	int rowsToAdd = rowCount - dataVector.size();
+	addExtraRows(rowsToAdd, columnCount);
+      }
+  }
+
+  /**
+   * This method adds some rows to <code>dataVector</code>.
+   *
+   * @param rowsToAdd number of rows to add
+   * @param nbColumns size of the added rows
+   */
+  private void addExtraRows(int rowsToAdd, int nbColumns) {
+    for (int i = 0; i < rowsToAdd; i++) 
+      {
+	Vector tmp = new Vector();
+	tmp.setSize(nbColumns);
+	dataVector.add(tmp);
+      }     
+  }
+
+  /**
    * Returns <code>true</code> if the specified cell can be modified, and
    * <code>false</code> otherwise.  For this implementation, the method
    * always returns <code>true</code>.

