Re: JTree node partially visible



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.
.



Relevant Pages

  • Step by step expanding multilevel collapsible navigation bar
    ... like to let you know that my company offers custom menu ... and sitemap controls. ... But when I click on the + Icon to expand a ...
    (microsoft.public.sharepoint.portalserver)
  • Re: Outline Levels in Different Views
    ... deleted a custom table but never took it off the view I was trying ... the normal Gantt/Entry view I have collapsed some outline ... I have to delete my custom view in order to get the expand ...
    (microsoft.public.project)
  • Re: Outline Levels in Different Views
    ... create some custom tables and views but when I try to go back to ... MS Project will not allow me expand the sections ... "JulieS" wrote: ...
    (microsoft.public.project)
  • Re: Sending a link, unable to select "send a link"
    ... Click Custom. ... Expand the menu (at the ... I followed the help article and added the "read mail" ... The selections are there but unable to select. ...
    (microsoft.public.windows.vista.general)