JTable - Cannot set background color of selected cell
Hi,
I want to set the background color of the selected cell but the renderer colors the slected cell AND some neighbouring cells as well. Please can any one tell me what is the wrong thing I am doing
privateclass SpecialCellRendererextends JLabelimplements TableCellRenderer
{
public SpecialCellRenderer()
{
this.setOpaque(true);
}
public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected,boolean hasFocus,int row,int col)
{
if (hasFocus && isSelected)
{
setBackground(TABLE_SELECTED_COLOR);
}
else
{
setBackground(TABLE_UNSELECTED_COLOR);
}
}
returnthis;
}

