I have a boolean column in JTable, so i each cell there is a checkbox. When i try to set a cell renderer in order to change the background color the checkbox from cell replaced by values (true, false).. What's goin wrong!!
My cell renderer:
class BackgroundTableCellRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int col) {
Component c = super.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, col);
if(row%2 == 0)
{
Color bColor = Color.decode("#EFF2ED");
c.setBackground(bColor);
}
else
c.setBackground(Color.white);
return c;
}
}
I set the renderer like that:
data_table.setDefaultRenderer(Boolean.class, new BackgroundTableCellRenderer());