@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; }
@NotNull private RendererComponent getEditorPanel(final JTable table) { RendererComponent panel = UIUtil.getClientProperty(table, MY_PANEL_PROPERTY); if (panel != null) { DelegateColorScheme scheme = (DelegateColorScheme) panel.getEditor().getColorsScheme(); scheme.setDelegate(EditorColorsManager.getInstance().getGlobalScheme()); return panel; } panel = createRendererComponent(myProject, myFileType, myInheritFontFromLaF); Disposer.register(this, panel); Disposer.register( this, new Disposable() { @Override public void dispose() { UIUtil.putClientProperty(table, MY_PANEL_PROPERTY, null); } }); table.putClientProperty(MY_PANEL_PROPERTY, panel); return panel; }
@Override protected void paintChildren(Graphics g) { updateText(g.getClipBounds()); super.paintChildren(g); }