This particular tooltip is really powerful. It is a gift that the Editor Code Completion API gives you: without even calling up the code completion box, you can make use of the API. Now, when I press Alt-P over any word, i.e., without calling up the code completion box, I get a tooltip that is populated by a web service (the same web service used in previous blog entries to populate the documentation section of the code completion box):
In this particular case, the tooltip appears and defines the word "other", here making use of a thesaurus so that without invoking code completion, I can immediately see alternative words for the currently typed word. If you use CompletionProvider.getAutoQueryTypes(), you can make the tooltip appear automatically, so that the user doesn't need to know about the Alt-P binding.
To make all this possible, this is now the end of my query method in the CompletionProvider:
JToolTip tooltip = new JToolTip();
And the getDefinitionsFromWS(filter) method is the same as that used for filling the documentation section of the code completion box, which is described in the Code Completion tutorial.
The tooltip thingy on the CompletionProvider is really cool, I think, especially because of its separation from the code completion box.