public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
ServiceItem serviceItem;
if (table.getModel() instanceof ServiceListTable){
serviceItem = ((ServiceListTable) table.getModel()).getServiceItem(row);
}else{
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
String text = "";
if (value != null){
text = value.toString();
}
setText(text);
if (column == ServiceListTable.COLUMN_TITLE){
setIcon(serviceItem.getIcon());
}else{
setIcon(null);
}
if(isSelected){
setBackground(table.getSelectionBackground());
setForeground(table.getSelectionForeground());
}else{
setForeground(table.getForeground());
Color c = serviceItem.getBackgroundColor();
if (c != null) {
setBackground(c);
}
}