I have an 'AbstractTableModel' subclass that display 3 columns with Drag & Drop processing from a center column cell [Drag] to a right most column cell [Drop]. The Table Model manages an ArrayList<String> component that holds the row, column parameters.
I have a 'TransferHandler' subclass that services the above DnD capability. It contains 'Override' methods for the following methods:
createTransferable; exportDone; canImport; importData;
The Table Model also is designed to insert a new row if the Drop column element has a non-null String. This is accomplished in my 'importData' override method. I add a row of data to the ArrayList and increment the Table Model 'nRow' parameter.
My problem is that when the 'AbstractTableModel' listener invokes my 'exportDone' override method the JTable component derived from the 'exportDone' 'JComponent' argument is still set to the 'Drop' column before the row was added.
I tried selecting the next row of the JTable in the 'importData' override method and in the 'addRow' method of the Table Model to no avail.
I could not find a better way to fix this so I coded what looks like a 'kludge' [to me]. The 'kludge' works fine but I am wondering if there is a better way to manipulate the JTable instance so that the 'exportDone' will be given the adjusted row index.
The 'kludge' is to set a boolean flag [fAddedRow] in my 'addRow' Table Model method and to use that flag in my 'exportData' override method to increment the row iff the flag is set.