*/
private void applyColumnOrder (JTableComponent component, JTableModel model) {
List columns = model.getColumns();
javax.swing.table.TableColumnModel componentColumnModel = component.getColumnModel();
for (int index = 0; index < columns.size(); index++) {
TableColumnModel columnModel = (TableColumnModel) columns.get(index);
String columnName = columnModel.getText();
int currentIndex = componentColumnModel.getColumnIndex(columnName);
int destinationIndex = columnModel.getColumnOrder();
// is it a valid destination index?
if (destinationIndex >= 0 && destinationIndex <= componentColumnModel.getColumnCount()) {
componentColumnModel.moveColumn(currentIndex, columnModel.getColumnOrder());
} else if (currentIndex != index) {
// was trying to be moved... so just put it at the end
componentColumnModel.moveColumn(currentIndex, columns.size() - 1);
}
}