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

前端 未结 8 1799
时光说笑
时光说笑 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:30

    I have used the "The 'Let's try to block the normal behavior with what we actually have' method" approach. Gnoupi said that he did not solve the second part of the problem. Here is the solution for just Windows XP L&F:

    1. copy XPStyle class to yourself.
    2. extend WindowsTableHeaderUI. Take a look at the source code.
    3. use it: getTableHeader().setUI(new TreeTableWindowsTableHeaderUI());

    Thanks to Gnoupi for the efforts.

提交回复
热议问题