JTable Moving Columns and keeping the index for re-display
I have a JTable with data.The data in the table is refreshed every two minutes. The user is allowed to move the columns around, but when the refresh happens, the columns go back to their original layout. I have a TableColumnModelListener attached to the table and I know that there is a columnMoved method and I can capture the the "toIndex" but where do I set this new index in the model?
[396 byte] By [
lewkima] at [2007-11-26 17:41:47]

# 1
The TableColumnModel controls the ordering of the the Table columns.
When you use the setModel(...) method the fireTableStructureDataChanged() event is fired. This causes the TableColumnModel to be recreated. However you can turn this off, assuming the structure of the TableModel is the same, and only the data has changed. After creating the table the first time you can use:
table.setAutoCreateColumnsFromModel( false );