What's Happening

Expandable ToolTip in Java

Jul 22nd, 2008 by blog | 4

Synopsis

ToolTips in Java are handy to explain the function of a button or other component, however, describing the function in not even a sentence is sometimes pretty hard. Sure, you can provide a “help” document to supplement but finding the comment about this particular element sometimes just takes too. So wouldn’t it be ideal to combine both: a quick toolTip when you scroll over the element that is expandable to a full blown help document.

The ExpandableToolTip-Class I wrote does exactly this, it opens a toolTip-like popUp after 1.3s, which displays the ToolTip text and instructions how to open the “expanded” help-version if needed.

The expanded version of this contains a HTML page which can be scrolled through, marked and copied into the clipboard. Since it is HTML you can format it the way you want.

Usage

Usage of ExpandableToolTip is as easy as generating a new instance with the component, it should be attached to, and the help texts as arguments:

JButton element = new JButton("I'm a Button");
String tooTipText="Text for ToolTip";
String helpText="<p>Text for expanded toolTip</p>";
new ExpandableToolTip(tooTipText,helpText,element);

Download

You can download the class from here :

expandableToolTip.java

Comparing ToolTipExpander to other available classes:

I found other approaches, like the Multi-line ToolTip by Zafir Anjum, but non offered an expansion to a HTML page. The “function-info” in eclipse has the properties I wanted (a ToolTip-like one line explanation, which can be expanded by ‘Press F2 to focus’) but I could not find the source code for it and I doubt that it’ll be a one-class thing.

License

Creative Commons License
Expandable ToolTip by www.allPower.de is licensed under a Creative Commons Attribution 3.0 Unported License.

4 Comments on “Expandable ToolTip in Java”


  1. Stefan said:

    Nicely done ;-)


  2. Stefan said:

    Hi Denis,

    under which license do yo release this code. Can it be used in commercial applications and if so under which terms?

    Stefan


  3. Mauricio said:

    Hi, im here wondering the same thing as stefan did some months ago, so:

    under which license do yo release this code. Can it be used in commercial applications and if so under which terms?

    Thanks in advance,

    Mauricio


  4. blog said:

    I added the license info

Leave a Reply