I am using a table to display data.
I am providing checkbox to each row of a table to perform some operations based on selection. When I did like that, I am able to check multiple rows.
But my requirement is, at any point of time I should check only one checkbox. To be precise, I need the behavior of Buttongroup to all checkboxes in table.
How can I do this?
                        
If you really want to use checkboxes, I assume your
TableModelholds a boolean for those checkboxes. It should be trivial to move the logic for the single selection to theTableModel.If you do not need the checkboxes but just want to operate on the selected rows (see
JTable#getSelectedRows), you can adjust theListSelectionModelwhich is present on theJTableto only allow for single selection (seeListSelectionModel#SINGLE_SELECTION)