Book Home Java Enterprise in a Nutshell Search this book

3.4. Tooltips

A Swing component can display context-sensitive help to the user in the form of a tooltip: a small window that pops up when the user lets the mouse rest over the component. You can display text in this window that explains the purpose or function of the component. Specify this text with the setToolTipText() method. This toolTipText property is inherited from JComponent, so it is shared by all Swing components.

While it is a good idea to provide tooltips for the benefit of your novice users, your experienced users may find them annoying, so it is nice to provide a way to turn them off. You can do this programatically by setting the enabled property of the ToolTipManager object. The code looks like this:

ToolTipManager.sharedInstance().setEnabled(false);


Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.