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 / GUI / February 2010

Tip: Looking for answers? Try searching our database.

ToolTips for JTree nodes

Thread view: 
Felix Natter - 06 Feb 2010 13:43 GMT
hello,

I am using a JTree with a custom model (tree nodes are domain objects,
not DefaultMutableTreeNodes).

in my TreeCellRenderer's getTreeCellRendererComponent method,
I create a DefaultTreeCellRenderer:

 DefaultTreeCellRenderer TCR = new DefaultTreeCellRenderer();

modify layout properties, add a Tooltip:

 TCR.setToolTipText("hello world");

and pass the arguments to its getTreeCellRendererComponent method:

 return TCR.getTreeCellRendererComponent(tree, value, selected,
                                         expanded, leaf, row, hasFocus);

Unfortunately, the tooltips don't show up in the GUI.

Do you have any hints?

Thanks in Advance!
Signature

Felix Natter

Java coder - 06 Feb 2010 14:38 GMT
Felix Natter a écrit :
> hello,
>
[quoted text clipped - 18 lines]
>
> Do you have any hints?

Yes, you need to register the JTree to the shared tooltip manager. And
BTW, you shouldn't create a new renderer for each call of
getTreeCellRendererComponenet, see JTree.setCellRenderer.
Felix Natter - 06 Feb 2010 21:47 GMT
> Felix Natter a écrit :
>> hello,
[quoted text clipped - 21 lines]
>
> Yes, you need to register the JTree to the shared tooltip manager.

Thanks, this works.

> And BTW, you shouldn't create a new renderer for each call of
> getTreeCellRendererComponenet, see JTree.setCellRenderer.

I guess I should save the TCR as an instance in my model.

Thanks!
Signature

Felix Natter



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



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