I have run into a slight issue and am struggling to resolve it. Basically what is happening is that I have a JTable which is being populated by an array that I get from an API call.
What I currently have is that if a device shows as online it will change GREEN, if offline, then a light-gray.
The problem is that it is affecting the entire ROW and not just the status CELL. I only want the status cell to highlight green. Any help would be really appreciated.
custTable = new javax.swing.JTable(model){
@Override
public Component prepareRenderer(TableCellRenderer renderer, int rowIndex,
int columnIndex) {
JComponent component = (JComponent) super.prepareRenderer(renderer, rowIndex, columnIndex);
if(getValueAt(rowIndex,1).toString().equalsIgnoreCase("Online"))
{
component.setBackground(Color.GREEN);
}
else if(getValueAt(rowIndex,1).toString().equalsIgnoreCase("Offline"))
{
component.setBackground(Color.lightGray);
}
return component;
}