Geertjan is a DZone Zone Leader and has posted 457 posts at DZone. You can read more from them at their website. View Full User Profile

JavaHelp & Continuation Tips

06.03.2008
| 3377 views |
  • submit to reddit

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.

AttachmentSize
continuation-javahelp.png7.46 KB
Published at DZone with permission of its author, Geertjan Wielenga.

Comments

Artur Biesiadowski replied on Tue, 2008/06/03 - 10:56am

I have seen the title and hoped for some kind of Continuation tips... But unfotunately time has not yet come.

Steven Baker replied on Tue, 2008/06/03 - 8:28pm

yeh, this is pretty useless

Geertjan Wielenga replied on Tue, 2008/06/03 - 10:56pm in response to: Steven Baker

[quote=zynasis]yeh, this is pretty useless[/quote]

?

Steven Baker replied on Tue, 2008/06/03 - 11:07pm in response to: Geertjan Wielenga

?

Konstantin Chikarev replied on Wed, 2008/06/04 - 6:51am in response to: Steven Baker

You mean useful? :)

I think its useful

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.