private static Component setLabelColors( 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; }
@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean selected, boolean focused, int row, int column) { RendererComponent panel = getEditorPanel(table); EditorEx editor = panel.getEditor(); editor.getColorsScheme().setEditorFontSize(table.getFont().getSize()); editor .getColorsScheme() .setColor(EditorColors.SELECTION_BACKGROUND_COLOR, table.getSelectionBackground()); editor .getColorsScheme() .setColor(EditorColors.SELECTION_FOREGROUND_COLOR, table.getSelectionForeground()); editor.setBackgroundColor(selected ? table.getSelectionBackground() : table.getBackground()); panel.setSelected(!Comparing.equal(editor.getBackgroundColor(), table.getBackground())); panel.setBorder( null); // prevents double border painting when ExtendedItemRendererComponentWrapper is used customizeEditor(editor, table, value, selected, row, column); return panel; }