Hi,
I have a JTable with a renderer to set the text color for the row if certain conditions exist.
The code below "works" although I have two issues:-
1. The command "table.setForeground(Color.BLUE);" in the code below causes 50% CPU utilisation (Win XP, service pack 3). Very strange and consistent - tested on two different PCs.
2. At times, the first column
below the intended column changes color. The rest of the intended column has color set correctly.
I'm using beans binding with the table concerned so can't post the table model - I believe the binding effectively has it's own model.
Be greatful for any insight as it seems v. strange.....
Thanks,
</code>
...
...
masterTable.setDefaultRenderer(String.class, textColour);
...
...
...
TableCellRenderer textColour = new TableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
MailingList mL = (MailingList) queryList.get((table.convertRowIndexToModel(row)));
table.setForeground(Color.BLACK);
if (mL.getApplicationAppId() != null) {
if (mL.getApplicationAppId().getSembookingsCollection() != null) {
Collection sB = mL.getApplicationAppId().getSembookingsCollection();
if (!sB.isEmpty()) {
// table.setForeground(Color.BLUE); //this line causes 50% CPU utilisation ???
}
}
}
TableCellRenderer delegate = table.getDefaultRenderer(Object.class);
return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
};
{code}