How can I explicitly display a tooltip in AWT?

Christophe Caissotti

Here's some sample code that can display a tooltip in an AWT GUI.

Users can see information each time they move the mouse on a GUI. This little class displays tips given by a String. The String can include five Html tags: <br><b><i></i></b>

You can download the class file at http://www.chez.com/ccaissotti/components/tipProducer.java

To display a tip, just create a TipProducer with the String you want to show and call its draw() method.

For example

public void onMouseMove( MouseEvent me ) {
  tp = new tipProducer();
  tp.setString("Click on the point<br>x=<b>" + me.getX() +
               "</b>" );
  tp.draw(g, me.getX(), me.getY );