Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

JTree node partially visible

Thread view: 
akhila - 31 Jan 2008 12:15 GMT
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.
Daniele Futtorovic - 31 Jan 2008 20:38 GMT
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.