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

前端 未结 8 1809
时光说笑
时光说笑 2020-11-30 09:17

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 re

8条回答
  •  醉话见心
    2020-11-30 09:38

    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

提交回复
热议问题