Get Selected Rows in JTable using AbstractTableModel

后端 未结 2 797
无人共我
无人共我 2020-11-22 13:22

I have a JTable using AbstractTableModel where I have a JCheckBox in the first column for selecting rows. Now, I need to get the selec

2条回答
  •  [愿得一人]
    2020-11-22 13:58

    I agree with kleopatra. When you create a subclass of the AbstractTableModel, you'll override the setValue( Object value, int rowIndex, int colIndex ). In your overridden method, you just check if the column is the one with your check box, and if so, update the internal data structure appropriately. You can also add a method getCheckedRows() that returns a List< Integer > with the rows in which the check boxes have been selected.

提交回复
热议问题