Since yesterday, one of the popular articles on DZone is entitled Tips and Tricks for JTree, JList, and JComboBox. I didn't get further than the first tip—that about JTree—because it responded exactly to one of my pet peeves about JavaHelp: when the width of a JavaHelp explorer window is less than the length of the text of an item contained within it, the additional text is not shown. Instead, it would be better if the additional text were to be shown as a tooltip.
However, as the article points out, the problem is not the absence of a tooltip. The problem is the absence of a continuation tip:
Continuation tips are different from tooltips in that the continuation tips are displayed instantly when the mouse is moved over an item and are displayed in the same place as the node in the tree. Tooltips on the other hand are displayed when the mouse is paused over a node for some time and are displayed below the mouse pointer. Moreover, continuation tips are not displayed if the item is fully visible.
And that's exactly what JavaHelp needs! The author of the article recommends Tim Boudreau's solution to the problem. All the code for Tim's solution is provided via the article. The Javadoc at the top of the class is as follows, responding exactly to the problem at hand:
* Displays pseudo-tooltips for tree and list views which don't have enough
I simply downloaded the class and then checked out the sources of JavaHelp which, since being open sourced, are in the Subversion repository at https://javahelp.dev.java.net/.
Then, only needing to identify the classes that define the views, I needed to do no more than the following within them, at the appropriate place:
And then, Tim's ViewTooltips class being in the same package, everything was handled for me, so that (only) when texts are longer than the width of the explorer, and the mouse moves over the text, is a "continuation tip" displayed, as shown here in the Search window of my modified version of JavaHelp:
So that's a really useful piece of code and very relevant in the context of JavaHelp. However, the sooner this becomes a standard part of JTree functionality, the better.