Committed as follows:

2006-05-08  Roman Kennke <[EMAIL PROTECTED]>

        PR 27486
        * javax/swing/JTable.java
        (setValueAt): Allow setting values even when table is editable.


/Roman

Am Montag, den 08.05.2006, 12:58 +0000 schrieb yvan dot norsa at gmail
dot com:
> 
> ------- Comment #3 from yvan dot norsa at gmail dot com  2006-05-08 12:58 
> -------
> (From update of attachment 11408)
> >Index: javax/swing/JTable.java
> >===================================================================
> >RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v
> >retrieving revision 1.99
> >diff -u -r1.99 JTable.java
> >--- javax/swing/JTable.java  5 May 2006 09:41:15 -0000       1.99
> >+++ javax/swing/JTable.java  8 May 2006 12:47:20 -0000
> >@@ -3586,8 +3586,7 @@
> >   }
> >   
> >   /**
> >-   * Set value for the cell at the given position. If the cell is not 
> >-   * editable, this method returns without action. The modified cell is
> >+   * Set value for the cell at the given position. The modified cell is
> >    * repainted.
> >    * 
> >    * @param value the value to set
> >@@ -3596,8 +3595,6 @@
> >    */
> >   public void setValueAt(Object value, int row, int column)
> >   {
> >-    if (!isCellEditable(row, column))
> >-      return;
> >     dataModel.setValueAt(value, row, convertColumnIndexToModel(column));
> >     
> >     repaint(getCellRect(row, column, true));
> 
> 
-- 
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: javax/swing/JTable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v
retrieving revision 1.99
diff -u -1 -0 -r1.99 JTable.java
--- javax/swing/JTable.java	5 May 2006 09:41:15 -0000	1.99
+++ javax/swing/JTable.java	8 May 2006 13:22:25 -0000
@@ -1886,22 +1886,27 @@
    * listener instead.
    */
   public void columnSelectionChanged (ListSelectionEvent event)
   {
     // Does not make sense for the table with the single column.
     if (getColumnCount() < 2)
       return;
     
     int x0 = 0;
     
-    int idx0 = event.getFirstIndex();
-    int idxn = event.getLastIndex();
+    // We must limit the indices to the bounds of the JTable's model, because
+    // we might get values of -1 or greater then columnCount in the case
+    // when columns get removed.
+    int idx0 = Math.max(0, Math.min(getColumnCount() - 1,
+                                    event.getFirstIndex()));
+    int idxn = Math.max(0, Math.min(getColumnCount() - 1,
+                                    event.getLastIndex()));
     int i;
 
     for (i = 0; i < idx0; i++)
       x0 += columnModel.getColumn(i).getWidth();
     
     int xn = x0;
     
     for (i = idx0; i <= idxn; i++)
       xn += columnModel.getColumn(i).getWidth();
     
@@ -3579,32 +3584,29 @@
    * to get the value.
    * 
    * @return the cell value, as returned by model.
    */
   public Object getValueAt(int row, int column)
   {
     return dataModel.getValueAt(row, convertColumnIndexToModel(column));
   }
   
   /**
-   * Set value for the cell at the given position. If the cell is not 
-   * editable, this method returns without action. The modified cell is
+   * Set value for the cell at the given position. The modified cell is
    * repainted.
    * 
    * @param value the value to set
    * @param row the row of the cell being modified
    * @param column the column of the cell being modified
    */
   public void setValueAt(Object value, int row, int column)
   {
-    if (!isCellEditable(row, column))
-      return;
     dataModel.setValueAt(value, row, convertColumnIndexToModel(column));
     
     repaint(getCellRect(row, column, true));
   }
   
   /**
    * Get table column with the given identified.
    * 
    * @param identifier the column identifier
    * 

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to