Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep a single column from being reordered in a JTable?

Tags:

People also ask

How do you make a JTable column not editable?

Right-click on the table cells. From popup menu, choose "Table Contents..". Uncheck the editable check box for the column you want to make it non-editable.

How can I tell if a row is selected in JTable?

So you can call table. getSelectionModel(). isSelectionEmpty() to find out if any row is selected.


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.