I want to add checkbox in a table column. I used following code for this.
I am able to get checkboxes in a column....but the issue is ... they are not selectable i.e. I am not able to tick them...
Also, I would like to know how we can get row value for which checkbox is checked ??
But since I am very new to Swings, was unable to modify that code as per my requirement .. tried a lott ...
My requirement is very simple.. There are 2 columns in a table .. 1st -> Checkbox ... 2nd -> Name .. and there is one button (OK).. Onclick of button OK ... I want a list which contains values (Names) for which checkbox is checked ... It's very basic requirement ... It would be really helpful if someone provide sample code for this ..
I want a list which contains values (Names) for which checkbox is checked ...
1) Create a loop
2) use the model.getValueAt(...) method to get the value from the column containing the Boolean value
3) if ( theValue.equals( Boolean.TRUE ) ) then get the Name from the model using the getValueAt() method for the current row and specific column.
I am using the code similar to code posted in previous post
I don't see your SSCCE posted anywhere that shows the similiar code. The key is to override the getColumnClass() method of the JTable or the model to return the proper class so the table can choose the proper renderer and editor to use.