I followed the directions somewhere online to insert checkboxes in a JTable. Here is my code to do so:
protected class JTableCellRenderer implements TableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
JCheckBox rendererComponent = new JCheckBox();
rendererComponent.setSelected((Boolean) tableModel.getValueAt(row,
column));
return rendererComponent;
}
}
I managed to add checkboxes to a JTable, but then when I run my program, I get the following behavior:
How do I allow a user to check the checkbox instead of selecting True or False from the dropdown menu when he or she clicks on the checkbox? Thanks!