I have a situation where i need to implement a custom tree cell renderer.
My specification is to have only a checkbox node and text for the parent node and not the folder icon that is used in the default tree cell renderer.
I achieved it through the following code snippet.
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
JLabel l = (JLabel)renderer.getTreeCellRendererComponent(
tree, "", true, expanded, leaf, row, true);
l.setIcon(null);
l.setText(value.toString());
panel.removeAll();
panel.add(this, BorderLayout.WEST);
panel.add(l);
return panel;
}
The screen shot of the result is like this .

Now you can see the grey area enclosing the text “One” .
Can you guide me as to clear the grey area ?
The output must look something that does not have the grey around the text.
🙂
For this issue is there very simple workaround to
setBackgroundinTreeCellRendererwithColorthat returnsexample from yesterday included