@ Override public Component prepareRenderer ( TableCellRenderer renderer , int row , int column ) { Component c = super . prepareRenderer ( renderer , row , column ) ; if ( ! isCellSelected ( row , column ) ) { c . setBackground ( colorForRow ( row ) ) ; c . setForeground ( UIManager . getColor ( "Table.foreground" ) ) ; } else { c . setBackground ( UIManager . getColor ( "Table.selectionBackground" ) ) ; c . setForeground ( UIManager . getColor ( "Table.selectionForeground" ) ) ; } return c ; }
Shades alternate rows in different colors .