-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
merlin
-
sparc
-
solaris_2.5.1
Name: aaC67449 Date: 06/01/98
DefaultTableModel.moveRow(...) moves rows incorrectly.
javadoc says:"
public void moveRow(int startIndex,
int endIndex,
int toIndex)
Moves one or more rows starting at startIndex to endIndex in the model to the toIndex. This method will send a
tableChanged() notification message to all the listeners.
Examples of moves:
1. moveRow(1,3,5);
a|B|C|D|e|f|g|h|i|j|k - before a|e|f|B|C|D|g|h|i|j|k - after
2. moveRow(6,7,1);
a|b|c|d|e|f|G|H|i|j|k - before a|G|H|b|c|d|e|f|i|j|k - after
Parameters:
startIndex - the starting row index to be moved
endIndex - the ending row index to be moved
toIndex - the destination of the rows to be moved
Throws:
ArrayIndexOutOfBoundsException - if any of the indices are out of range. Or if endIndex is less than
startIndex.
"
The following example represent the first example from javadoc, and its results are different from javadoc ones.
------------------Example-----------------------------------
import java.awt.swing.table.*;
import java.util.*;
public class Test {
public static void main(String argv[]) {
int results[]={0,4,5,1,2,3,6,7,8,9};
Vector elem=null;
DefaultTableModel c = new DefaultTableModel(0,1);
// create table {0,1,2, ... }
for(int k=0;k<10;k++) {
elem=new Vector();
elem.addElement(new Integer(k));
c.addRow(elem); // add row
}
c.moveRow(1,3,5); // move rows
for(int k=0;k<5;k++)
if(!(new Integer(results[k])).equals(c.getValueAt(k,0))){
System.out.println("Method works incorrectly:"+c.getDataVector());
System.out.println("Should be: {0,4,5,1,2,3,6,7,8,9}");
break;
}
}
}
-------------------Output------------------------------------
Method works incorrectly:[[0], [2], [4], [1], [3], [5], [6], [7], [8], [9]]
Should be: {0,4,5,1,2,3,6,7,8,9}
======================================================================