I have got a small problem.
My TableRenderer is supposed to color empty cells, instead the whole JTable gets colored.
I looked up "coloring single cells" on the internet and tried some ideas, but they didnt work.
here is my Renderer:
public class TransTableRenderer extends DefaultTableCellRenderer
{
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(value != null)
{
String[] values = value.toString().split("\\t s-p-l-i-t");
if(values[0].isEmpty())
{
setBackground(Color.RED);
}
this.setText(values[0]);
this.setToolTipText(values[1]);
}
return this;
}
}
...and thats how is set the Renderer:
JTable jt = new JTable();
jt.setDefaultRenderer(Object.class, new TransTableRenderer());
i appreciate every answer! thank you in advance :)