I want to programmatically deselect a row in JTable. Basically I have cehckbix in my jtable and my row needs to be selected or highlited when I click on checkbox. CLicking in any other column should not highlight the row.

I tries table.removeRowSelectionInterval(row,row) on clicking in cell other than checkbox it did not work.

I tried ListSelectionModelk.clearSelection() and then adding RowSelectionInterval() for rows as needed, it works but it interfere with some other functionality.

So I can't use this.

有帮助吗?

解决方案

As @Nizil commented that you can write your own Cell Renderer or Cell Renderer

You also need to look at How to use Tables and How to use CheckBoxes

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top