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

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 );
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact