Re: TreeCellRenderer.setIcon(null) -> performance loss
From: Piet (pit.grinja_at_gmx.de)
Date: 06/22/04
- Next message: Dave Thorn: "Re: custom component painting"
- Previous message: A. Bolmarcich: "Re: custom component painting"
- In reply to: Thomas Weidenfeller: "Re: TreeCellRenderer.setIcon(null) -> performance loss"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 21 Jun 2004 23:44:02 -0700
Hi Thomas,
> I really don't understand what is your issue here. If you don't want to
> have something displayed, don't let the model give it to the tree. The
> easiest way a model doesn't give a node to the tree is to let the model
> not have that node at all.
>
> So, why do you put something (the empty elements) in the tree, if you
> don't want to display them? If you never want to see them, they
> shouldn't have been put in the model at all. If you need the tree
> contents dynamically changing based on some preference, implement a
> filtering tree model as a wrapper around your real data.
Actually, I do not put anything in the tree, at least not explicitly.
I defined my tree model by implementing the TreeModel interface and
creating functions like getRoot, getChildren asf. by filling then with
Xml DOM commands that would return the information required by the
JTree. I was surprised to see that this simple approach really worked
and that I didnīt have to add anything explicitly to the tree. The
tree is basically build "automatically" when the XML document is
parsed. I then tried to modify the commands that e.g. return the
number of children but that was a big hassle and basically didnīt
bring me a step forward.
So what I was looking for was a mechanism that would allow me to make
some nodes "invisble" so that they would still be in the DOM but not
displayed in the JTree. One approach aling these lines was to create a
TreeCellRenderer that should hide the tree label by using the
"this.setVisible(false)" method, but that didnīt work.
However, your are not the first and only one who doesnīt get the
point. I think about a different approach by constructing the JTree
from simple DefaultTreeNodes and attaching the XML node object to the
DefaultTreeNode objects via get/setClientData and get a good Swing
book ASAP.
Regards
Peter
- Next message: Dave Thorn: "Re: custom component painting"
- Previous message: A. Bolmarcich: "Re: custom component painting"
- In reply to: Thomas Weidenfeller: "Re: TreeCellRenderer.setIcon(null) -> performance loss"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|