Allowing the User to Move a Column in a JTable Component
By default, a table allows the user to reorder its columns.
This example demonstrates how to disable this feature.
int rows = 3;
int cols = 3;
JTable table = new JTable(rows, cols);
table.getTableHeader().setReorderingAllowed(false);
// Programmatically moving a column is still possible
table.moveColumn(table.getColumnCount()-1, 0);
// the last column is moved to the first position
Post a comment