table.getColumnModel().addColumnModelListener(
new MyTableColumnModelListener(table));
public class MyTableColumnModelListener implements TableColumnModelListener {
JTable table;
// It is necessary to keep the table since it is not possible
// to determine the table from the event's source
public MyTableColumnModelListener(JTable table) {
this.table = table;
}
public void columnAdded(TableColumnModelEvent e) {
}
public void columnRemoved(TableColumnModelEvent e) {
}
public void columnMoved(TableColumnModelEvent e) {
System.out.println("column moved");
}
public void columnMarginChanged(ChangeEvent e) {
}
public void columnSelectionChanged(ListSelectionEvent e) {
}
}