| View previous topic :: View next topic |
| Author |
Message |
Sharon Guest
|
Posted: Sat May 13, 2006 10:07 am Post subject: paint visited leaf's in JTree |
|
|
is it possible to paint (in red for example) .
visited leafs of a JTree ?
Thank you
Sharon |
|
| Back to top |
|
 |
Oliver Wong Guest
|
Posted: Sat May 13, 2006 9:07 pm Post subject: Re: paint visited leaf's in JTree |
|
|
"Sharon" <Sharon669 (AT) hotmail (DOT) com> wrote in message
news:4465a2f9 (AT) news (DOT) bezeqint.net...
| Quote: | is it possible to paint (in red for example) .
visited leafs of a JTree ?
|
Yes. You'd design your model to keep track of which nodes were visited,
and provide a custom renderer for the tree.
- Oliver |
|
| Back to top |
|
 |
Sharon Guest
|
Posted: Sun May 14, 2006 9:07 pm Post subject: Re: paint visited leaf's in JTree |
|
|
Hi Oliver and thank you
I have custom renderer , and I have a HashMap that saves the path of the
visited Leaf
But how dose the actual painting occurs?
Thanks again
Sharon
"Oliver Wong" <owong (AT) castortech (DOT) com> wrote in message
news:0Sr9g.11856$Qq.9267@clgrps12...
| Quote: |
"Sharon" <Sharon669 (AT) hotmail (DOT) com> wrote in message
news:4465a2f9 (AT) news (DOT) bezeqint.net...
is it possible to paint (in red for example) .
visited leafs of a JTree ?
Yes. You'd design your model to keep track of which nodes were visited,
and provide a custom renderer for the tree.
- Oliver |
|
|
| Back to top |
|
 |
Daniel Guest
|
Posted: Mon May 15, 2006 6:07 am Post subject: Re: paint visited leaf's in JTree |
|
|
If you have you already have your custom renderer it should be no
problem.
You have your method getTreeCellRendererComponent( ... )
in there you can either ask the tree for the model, "talk to" the
model some other way. if you just extend the DefaultTreeCellRenderer
it is a JLabel, so there you can change the colour easily.
something like
if(visited){
super.setForeground(ColorRED);
}else{
super.setForeground(Color.BLUE);
}
regards
Daniel
| Quote: | Hi Oliver and thank you
I have custom renderer , and I have a HashMap that saves the path of the
visited Leaf
But how dose the actual painting occurs?
Thanks again
Sharon
"Oliver Wong" <owong (AT) castortech (DOT) com> wrote in message
news:0Sr9g.11856$Qq.9267@clgrps12...
"Sharon" <Sharon669 (AT) hotmail (DOT) com> wrote in message
news:4465a2f9 (AT) news (DOT) bezeqint.net...
is it possible to paint (in red for example) .
visited leafs of a JTree ?
Yes. You'd design your model to keep track of which nodes were visited,
and provide a custom renderer for the tree.
- Oliver
|
|
|
| Back to top |
|
 |
|