I have a custom swing component that is implemented similar to a JTree. It has a ComponentUI that renders an object list using a CellRenderer. The tooltip now correctly shows for each rendered cell, however it doesn't track the mouse as I would like. For instance, if I have boxes layed out like this;
[ box A ] [ box B ] [ box C ] [ box D ]
If i drag the mouse across these boxes I will see the tooltip for box A where the mouse crosses the box A boundary. As I continue to move the mouse the tooltip will not track the pointer. When I leave the box the tooltip will appropriately disappear. When i cross box B the same thing happens.
My guess is that the tooltip is only updating the view when the contents of getToolTipText(MouseEvent event)
change. The behavior I would like is to have the tooltip track the pointer position regardless of the contents returned by getToolTipText
. A quick hack is to add and remove an empty space based on an even/odd number of calls to the method. This works, but bleh, it can't be the way I am supposed to do it.
I'm looking for a graceful non-hack way of solving this problem. I'm hoping someone knows of some arcane flag somewhere that forces the tooltip to follow the mouse regardless of mouse content.