I have written a renderer and my program does not color the cell and I don't know why. When I try to color the whole row it also colors only 3 of the 7 rows. Can someone please help me?
public void isLow(JTable jTableBestandstabelle) {
jTableBestandstabelle.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(
JTable aTable, Object aNumberValue, boolean aIsSelected,
boolean aHasFocus, int aRow, int aColumn
) {
if (aNumberValue == null) {
return this;
}
Component renderer = super.getTableCellRendererComponent(
aTable, aNumberValue, aIsSelected, aHasFocus, aRow, aColumn
);
int m = (int) jTableBestandstabelle.getValueAt(aRow, 4);
int a = (int) jTableBestandstabelle.getValueAt(aRow, 5);
if (a < m && column == 5) {
renderer.setForeground(Color.black);
renderer.setBackground(Color.red);
} else {
renderer.setForeground(Color.black);
}
return this;
}
});
}
public void isLow(JTable jTableBestandstabelle) {
jTableBestandstabelle.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(
JTable aTable, Object aNumberValue, boolean aIsSelected,
boolean aHasFocus, int aRow, int aColumn
) {
if (aNumberValue == null) {
return this;
}
Component renderer = super.getTableCellRendererComponent(
aTable, aNumberValue, aIsSelected, aHasFocus, aRow, aColumn
);
int m = (int) jTableBestandstabelle.getValueAt(aRow, 4);
int a = (int) jTableBestandstabelle.getValueAt(aRow, 5);
if (a < m) {
renderer.setForeground(Color.black);
renderer.setBackground(Color.red);
} else {
renderer.setForeground(Color.black);
}
return this;
}
});
}