Previous | Next | Trail Map | Creating a User Interface | Using the JFC/Swing Packages


How to Use Tool Tips

Creating a tool tip for any JComponent is easy. You just use the setToolTipText method to set up a tool tip for the component. For example, to add tool tips to the three buttons in the ButtonDemo program (explained in How to Use Buttons), you add only three lines of code:
b1.setToolTipText("Click this button to disable the middle button.");
b2.setToolTipText("This middle button does nothing when you click it.");
b3.setToolTipText("Click this button to enable the middle button.");
When the user of the program pauses with the cursor over any of the program's buttons, the tool tip for the button comes up. For example:


[Please imagine a cursor over the left button. Thank you.]

For more information about tool tips, read the documentation for the JToolTip(in the API reference documentation) and JComponent(in the API reference documentation) classes.


Previous | Next | Trail Map | Creating a User Interface | Using the JFC/Swing Packages