JTree node partially visible

A

akhila

Hi all,

I have issues with my custom Jtree. 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.

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

model.nodechanged()
model.nodeStructureChanged

tree node expansion, collapse didnt work for me.
 
D

Daniele Futtorovic

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top