Some apps were getting NPE with JTable because variables were not set
before the call to updateUI which could be overridden.  This is fixed
now, although there are some intricacies which may be fixed after the
release, I put a TODO in the code for now.

2005-11-01  Anthony Balkissoon  <[EMAIL PROTECTED]>

        * javax/swing/JTable.java:
        (JTable(TableModel, TableColumnModel, ListSelectionModel)): Call 
        updateUI after initializeLocalVars.  Manually set the lead selection
        indices.

--Tony
? JFileChooser.txt
Index: javax/swing/JTable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v
retrieving revision 1.57
diff -u -r1.57 JTable.java
--- javax/swing/JTable.java	1 Nov 2005 16:41:25 -0000	1.57
+++ javax/swing/JTable.java	1 Nov 2005 20:14:28 -0000
@@ -1081,12 +1081,23 @@
       {
         setColumnModel(createDefaultColumnModel());
         autoCreate = true;
-      }    
-    updateUI();
+      }        
     setSelectionModel(sm == null ? createDefaultSelectionModel() : sm);
     setModel(dm == null ? createDefaultDataModel() : dm);
     setAutoCreateColumnsFromModel(autoCreate);
     initializeLocalVars();
+    // The following four lines properly set the lead selection indices.
+    // After this, the UI will handle the lead selection indices.
+    // FIXME: this should probably not be necessary, if the UI is installed
+    // before the TableModel is set then the UI will handle things on its
+    // own, but certain variables need to be set before the UI can be installed
+    // so we must get the correct order for all the method calls in this
+    // constructor.
+    selectionModel.setAnchorSelectionIndex(0);    
+    selectionModel.setLeadSelectionIndex(0);
+    columnModel.getSelectionModel().setAnchorSelectionIndex(0);
+    columnModel.getSelectionModel().setLeadSelectionIndex(0);
+    updateUI();
   }    
 
   protected void initializeLocalVars()
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to