I have added couple of logic to it. Still i am not getting full row.
public void paint(Graphics g) {
if(rowNo%2 == 0)
{
g.setColor(Color.gray);
}
else
{
g.setColor(Color.white);
}
this.setOpaque(false);
this.setBackground(null);
Rectangle r = tree.getBounds();
System.out.println("X value "+r.x);
//Draw a rectangle in the background of the cell
g.fillRect(r.x, 0, 400, getHeight()-1);
super.paint(g);
}
> >>> Hi,
> >>> As part of tree, i wanted to display a alternative background row
[quoted text clipped - 45 lines]
>
> Steve
steve - 12 Jun 2006 22:40 GMT
> I have added couple of logic to it. Still i am not getting full row.
>
[quoted text clipped - 70 lines]
>>
>> Steve
what do you mean not getting a full row?
this is a jtree, not a jtable
also where did you set rowNo, and how did you calculate it?
The only way I can see this working is some sort of complex logic, starting
at the root.
I can assure you that the paint method IS called for each node, therefore it
is just a matter of you logic to flip the colours.
but i still do not understand why you are trying to apply a method ,that is
normally used for JTables to a JTree
steve - 12 Jun 2006 22:47 GMT
> I have added couple of logic to it. Still i am not getting full row.
>
[quoted text clipped - 70 lines]
>>
>> Steve
Ahh , when you say the full row, you mean including the ICON!!
Well i can tell you that it will get a lot more complex, if you want to try
and repaint the icons background on the fly.
basically the above code will only paint the label of the node.