I'm trying to change the JTable cell color (foreground). It is working but it's coloring the cell+1 and not the required cell (as you see in my code).
I'm trying to change the color of the current row and column 3 but, it's actually changing the color of next column.
This code is added in the custom code.
BaritemsTable = new javax.swing.JTable(){
@Override
public Component prepareRenderer (TableCellRenderer renderer, int rowIndex , int columnIndex ){
Component component = super.prepareRenderer(renderer , rowIndex , columnIndex );
Object value = getModel().getValueAt(rowIndex , columnIndex);
if (columnIndex == 3){
if (value.equals("Ready")){
BaritemsTable.setForeground(new java.awt.Color(51, 204, 0));
BaritemsTable.setFont(new Font("Tahoma", Font.PLAIN, 48));
}
if (value.equals("Process")){
BaritemsTable.setForeground(new java.awt.Color(51, 51, 255));
BaritemsTable.setFont(new Font("Tahoma", Font.PLAIN, 48));
}
if (value.equals("Queued")){
BaritemsTable.setForeground(new java.awt.Color(255, 0, 0));
BaritemsTable.setFont(new Font("Tahoma", Font.PLAIN, 48));
}
} else {
BaritemsTable.setForeground(new java.awt.Color(0, 0, 0));
BaritemsTable.setFont(new Font("Tahoma", Font.PLAIN, 48));
}
return component;
}
};