Hi, Soumitra,
Set your own TreeCellRenderer. For example, you could override
DefaultTreeCellRenderer.getTreeCellRendererComponent() to set the
background if a particular condition is true. See the simple example:
tree.setCellRenderer(new DefaultTreeCellRenderer() {
public Component getTreeCellRendererComponent(JTree tree,
Object value,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
if (expanded) {
setBackgroundNonSelectionColor(Color.white);
} else {
setBackgroundNonSelectionColor(null);
}
return super.getTreeCellRendererComponent(tree,
value,
sel,
expanded,
leaf,
row,
hasFocus);
}
});
--
Thanks,
Andrey.
> Soumitra Dhankar wrote:
>
>
>
> Hi All,
>
>
>
> I want to color only some nodes of a JTree programatically if a perticular condition
>is true.
>
> My nodes extends DefaultMutableTreeNode.
>
> Does anybody have an idea regarding this ?
>
>
>
>
>
> TiA,
>
> -Soumitra
>
>
>
>
>
>
>
> "The information in this e-mail, and any attachment therein, is
>
> confidential and for use by the addressee only. If you are not the
>
> intended recipient, please return the e-mail to the sender and delete
>
> it from your computer. Although The Bank of New York attempts to
>
> sweep e-mail and attachments for viruses, it does not guarantee that
>
> either are virus-free and accepts no liability for any damage sustained
>
> as a result of viruses."
>
> Name: Wipro_Disclaimer.txt
> Wipro_Disclaimer.txt Type: Plain Text (text/plain)
> Encoding: 7bit
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing