David
Location : Calgary, Alberta, Canada
Member since : Mar 19, 2004
Messages : 1
|
Mar 19, 2004 at 8:01 PM
There appears to be a bug in JeksTable#deleteSelectedCells() and JeksTable#pasteCopiedCells(). It appears that the constructor for JeksCellSet has its parameters mixed up. It is easy to generate a ArrayIndexOutOfBoundsException.
The line
updatedSet.addElement (new JeksCellSet (row, row + rowCount - 1, modelColumn, modelColumn));
should read
updatedSet.addElement (new JeksCellSet (row, modelColumn, row + rowCount - 1, modelColumn));
The junit test below will show the problem. An ArrayIndexOutOfBoundsException will be thrown:
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 10
at com.eteks.jeks.JeksTableModel.getValueAt(JeksTableModel.java:83)
..
at com.eteks.jeks.JeksTable.pasteCopiedCells(JeksTable.java:339)
at com.eteks.jeks.JeksTable.testPasteCopiedCells(JeksTableTest.java:36)
...
-----------------------------------------------------
package com.eteks.jeks;
import javax.swing.JFrame;
import junit.framework.TestCase;
/**
* @author David
*/
public class JeksTableTest extends TestCase
{
private JeksTable table;
public void testPasteCopiedCells()
{
table = new JeksTable(500,10);
table.setValueAt(new Integer(1), 0, 0);
table.setValueAt(new Integer(2), 1, 0);
table.setValueAt(new Integer(3), 2, 0);
table.setValueAt(new Integer(4), 3, 0);
table.setValueAt(new Integer(5), 4, 0);
table.setValueAt(new Integer(6), 5, 0);
table.setValueAt(new Integer(7), 6, 0);
table.setValueAt(new Integer(8), 7, 0);
// select to copy
table.setRowSelectionInterval(0,7);
table.setColumnSelectionInterval(0, 0);
table.copySelectedCells();
// select to paste
table.setRowSelectionInterval(8,8);
table.setColumnSelectionInterval(0, 0);
// throws an ArrayIndexOutOfBoundsException
table.pasteCopiedCells();
// show
// JFrame frame = new JFrame();
// frame.setSize(300, 700);
// frame.getContentPane().add(table);
// frame.show();
}
}
|