I created an application that retrieves datas from a Mysql database and displays them in a JTable. Then I added checkboxes in the 1st column and I am able to display them with TableCellRendere. But when I try to check them , the checkboxes are not checked. In fact, I read how to use properly a TableCellEditor in this link, but I didn't understand well:
Then I got this code but I don't know what to add in the method public Component getTableCellEditorComponent().
Here is the code which I need to complete:
public class CheckBoxCellEditor extends AbstractCellEditor implements TableCellEditor {
protected JCheckBox checkBox;
public CheckBoxCellEditor() {
checkBox = new JCheckBox();
checkBox.setHorizontalAlignment(SwingConstants.CENTER);
}
public Component getTableCellEditorComponent(
JTable table,
Object value,
boolean isSelected,
int row,
int column) {
// What should I add here and can you explain me
return checkBox;
}
public Object getCellEditorValue() {
return Boolean.valueOf(checkBox.isSelected());
}
}
Thanks
Aucun commentaire:
Enregistrer un commentaire