> 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
[quoted text clipped - 3 lines]
> 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.