How to keep a single column from being reordered in a JTable?
java, jtable, swing
Solution
I think that you need to override the `columnMoved()` method in `TableColumnModelListener`. the `TableColumnModelEvent` class has a `getFromIndex()` method that you should be able to look at to determine if it's your fixed column, and then you should be able to cancel the event.
Hope that helps. A
Problem
I have a `JTable` and I need to be able to reorder the columns. However I want the first column to not be able to be re-ordered. I used the following to enable reordering: ``` table.getTableHeader().setReorderingAllowed(true); ``` The columns can now be reordered including the first column which I don't want. Is there any way to lock the first column? I have seen some solutions that use two tables with the first column being in a separate table, but maybe there's a better/simpler way.