- Object[] temp = new Object[3];
- temp[0] = table.getValueAt(selectedRow, 0);
- temp[1] = table.getValueAt(selectedRow, 1);
- temp[2] = table.getValueAt(selectedRow, 2);
-
- table.setValueAt(table.getValueAt(newRow, 0), selectedRow, 0);
- table.setValueAt(table.getValueAt(newRow, 1), selectedRow, 1);
- table.setValueAt(table.getValueAt(newRow, 2), selectedRow, 2);
-
- table.setValueAt(temp[0], newRow, 0);
- table.setValueAt(temp[1], newRow, 1);
- table.setValueAt(temp[2], newRow, 2);
-
+ /*
+ * 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();
+ 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();