Re: JTree node partially visible
- From: Daniele Futtorovic <da.futt.newsLOVELYSPAM@xxxxxxxxxxx>
- Date: Thu, 31 Jan 2008 21:38:46 +0100
On 31.01.2008 13:15, akhila allegedly wrote:
Hi all,
I have issues with my custom Jtree.
I suppose you mean JTree.
What's custom about it? Did you override some functionalities of the
JTree class, or do you mean you use JTree with a custom TreeModel and/or
with a custom TreeCellRenderer?
When the tree is displayed the nodes are only partially visible. But
when I manually expand and collapse the nodes, they are in proper
size.
When you manually expand and collapse the nodes themselves, or their
parent nodes?
The node of the Tree is a Label followed by a TextPane. (Label for icons and TextPane for the text). I use TextPane because usually the
text will be more than 2 lines.
When the node of a Jtree is updated or added, the node becomes partially visible. Only the first line of the text is visible, the
rest of the text becomes visible only after I expand the node
Do you use a custom TreeCellRenderer? If yes, do you implement
TreeCellRenderer, or do you extend DefaultTreeCellRenderer?
I do not fully understand the part about collapsing and expanding, but
my hypothesis would be that the component you use for rendering the node
initially reports a wrong self-size to the tree's UI, a wrong size
according to which the UI sets a wrong clipping area for the Graphics so
that you see only part of the component.
I assume the following:
You use a normal JTree.
You may or may not use a custom TreeModel.
You use a custom TreeCellRenderer.
You probably did subclass DefaultTreeCellRenderer (because that class
handles validate() and the like in a special manner [they're noops])
You did implement your own version of
TreeCellRenderer#getTreeCellRendererComponent, returning a container,
probably JPanel, containing your label, text area, etc.
My hypothetical solution would be to call validate() on the container
you return in getTreeCellRendererComponent before you return it.
DF.
.
- References:
- JTree node partially visible
- From: akhila
- JTree node partially visible
- Prev by Date: Re: general performance question
- Next by Date: Null Pointer Exception when executing a Java software
- Previous by thread: JTree node partially visible
- Next by thread: Writing Application Specific Information to ID3 Tag
- Index(es):
Relevant Pages
|