I think you're making a basic mistake re: rendering components. In
default JTree implementations, *one* component is used to render the
entire tree. Moreover, the component isn't actually a child component
of the tree. Rather, the tree uses the JLabel renderer as a
"rubber-stamp" to draw the tree.
Which means that setting the renderer's tool tip text is going to give
you unpredictable results, at best. What you need to do, rather, is
update the tool tip text for the *JTree* dynamically via signals from a
mouse-motion listener. I.e., every time the mouse moves over a new
tree cell, you change the tool tip text for the JTree appropriately.
Walter Gildersleeve
Freiburg, Germany
___________________________________________
http://linkfrog.net
URL Shortening
Free and easy, small and green
Michael Rauscher - 29 Nov 2005 12:21 GMT
NullBock schrieb:
> Which means that setting the renderer's tool tip text is going to give
> you unpredictable results, at best. What you need to do, rather, is
Wrong. JTree overrides JComponent#getToolTipText(MouseEvent) in order to
make use of the renderer's tool tip text.
Setting the tool tip of the renderer component gives pretty predictable
results - at least as long as it's done in the
getTreeCellRendererComponent method.
Bye
Michael