int newRow = table.rowAtPoint(evt.getPoint());
if (newRow != selectedRow && selectedRow != -1 && newRow != -1)
{
+ /*
+ * reposition 'selectedRow' to 'newRow' (the dragged to location)
+ * this could be more than one row away for a very fast drag action
+ * so just swap it with adjacent rows until we get it there
+ */
Object[][] data = ((FeatureTableModel) table.getModel())
.getData();
- Object[] temp = data[selectedRow];
- data[selectedRow] = data[newRow];
- data[newRow] = temp;
+ int direction = newRow < selectedRow ? -1 : 1;
+ for (int i = selectedRow; i != newRow; i += direction)
+ {
+ Object[] temp = data[i];
+ data[i] = data[i + direction];
+ data[i + direction] = temp;
+ }
updateFeatureRenderer(data);
table.repaint();
selectedRow = newRow;