I have a Jtable with three column . The last columns contains checkboxes . I need to enfore single selection model on them . Although i know it can be done via adding a table change listener and enforcing its value to false everytime there is a change in table . But isnt there any other way of doing so . Likewise i mean a renderer to enforce Single selection of checkbox on that column or something similar to it. An example would be great help.
Asked
Active
Viewed 599 times
0
-
2_But isnt there any other way of doing so_ Yes: using the `TableModel`. Whenever `setValueAt` is called, you can perform the validation you want. `TableModelListener` 's are not made this. – Guillaume Polet May 22 '13 at 10:19
-
@GuillaumePolet shows an example [here](http://stackoverflow.com/a/11259671/230513) having a column rendered by `JRadioButton`, a component commonly used for exclusive selection. More alternatives are cited [here](http://stackoverflow.com/questions/11154378/can-i-add-jradiobutton-into-jtable/11173600#11173600). Please edit your question to include an [sscce](http://sscce.org/) that shows your selected approach and any problems you encounter. – trashgod May 22 '13 at 19:41