When a tool tip is displayed on a tree and the mouse is moved the tooltip stays visible and the text changes. Is it possible to hide the tool tip and redisplay it when the mouse moves from one item to the next.
A:
Extend DefaultTreeCellRenderer
and invoke setToolTipText()
as required. The tutorial project TreeIconDemo2
, discussed in Customizing a Tree's Display, demonstrates the approach.
Addendum: You can supply the desired text for each node in a TreeCellRenderer
, e.g. MyRenderer
:
setToolTipText(value + " is in the Tutorial series.");
trashgod
2010-06-21 15:04:15
i've tried that, but the tool tip does not disappear and reappear while moving one each node. the behavior i was trying to acheive was:Mouse over node1 ->show tooltip for node1Mouse over node2 -> hide tooltip for node1, n delay show tooltip for node2
jagguli
2010-07-10 20:30:05
@jagguli: It seems to work in the `TreeIconDemo2` mentioned above.
trashgod
2010-07-10 20:46:11
@jagguli: Oh, I see; you want the tool tip to come and go. You could use `ToolTipManager.sharedInstance()` and alter the delays.
trashgod
2010-07-10 20:55:21
I want the tool tip to disappear on mouse exit from one node,then reappear on mouse enter on the next node, not based on a delay. Maybe something in the tooltipui ?
jagguli
2010-08-14 14:15:22
Anyways its not a requirement for us anymore, the main concern was whether having the tool tip visible when mouse moves over a large tree would increase cpu utilization, so far it doesn't seem that way so its ok.
jagguli
2010-08-14 14:18:36
@jagguli: For scalability, the flyweight pattern pervades Swing, which uses renderers for many components.
trashgod
2010-08-14 15:52:43