Component (final Component label, final JTable table, final boolean isSelected, final int row) { if (label instanceof JComponent) { ((JComponent)label).setOpaque(true); } label.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground()); label.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground()); return label; }