Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

JavaHelp & Continuation Tips

DZone's Guide to

JavaHelp & Continuation Tips

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

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
* space.
*/

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:

ViewTooltips.register(tree); 

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.

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}