Component (JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row, boolean hasFocus) { Color background = RenderingUtil.getBackground(tree, isSelected); Color foreground = RenderingUtil.getForeground(tree, isSelected); if (value instanceof MyToggleTreeNode treeNode) { JToggleButton button = myCheckBox; button.setSelected(treeNode.isSelected); button.setForeground(foreground); button.setBackground(background); button.setVisible(true); button.setEnabled(tree.isEnabled() && treeNode.isEnabled()); mySearchStringProvider.setLabelText(myLabel, treeNode.getText(), SimpleTextAttributes.STYLE_PLAIN, foreground, background); } else { myCheckBox.setVisible(false); mySearchStringProvider.setLabelText(myLabel, value.toString(), SimpleTextAttributes.STYLE_BOLD, foreground, background); myLabel.setEnabled(tree.isEnabled()); } myCheckBoxPanel.setForeground(foreground); myCheckBoxPanel.setBackground(background); myLabel.setOpaque(true); return myCheckBoxPanel; }