Adding JToolTip to component : JToolTip « Swing « Java Tutorial






Tooltip text is normally one line long.

Calling the public void setToolTipText(String text) method from JComponent to create a tooltip.

Adding JToolTip to component
import javax.swing.JButton;
import javax.swing.JFrame;
public class ToolTipDemo {
  public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton b = new JButton("Hello, World");
    frame.add(b,"Center");
    b.setToolTipText("asdf");
    frame.setSize(300, 200);
    frame.setVisible(true);
  }
}








14.72.JToolTip
14.72.1.Adding JToolTip to componentAdding JToolTip to component
14.72.2.Creating HTML 3.2 formatted text tooltip: the text string begins with 'html' in any caseCreating HTML 3.2 formatted text tooltip: the text string begins with 'html' in any case
14.72.3.Creating Customized JToolTip Objects: customize and override its inherited public JToolTip createToolTip()
14.72.4.Displaying Positional Tooltip Text: display different tooltip depending on the mouse pointer's location
14.72.5.Displaying Mnemonics in tooltip textDisplaying Mnemonics in tooltip text
14.72.6.Label with tooltip
14.72.7.Use images in tooltips
14.72.8.Make a tool tips appear immediately
14.72.9.Use the default tool tip location
14.72.10.Setting the Location of a Tool Tip
14.72.11.Enabling and Disabling Tool Tips
14.72.12.Showing an Image in a Tool Tip
14.72.13.Italicize the second line
14.72.14.By default, the lines are left justified. Center the lines.
14.72.15.Showing Multiple Lines in a Tool Tip
14.72.16.Disable / enable application tool tips
14.72.17.Making Tool Tips Remain Visible
14.72.18.Set the location of the tool tip such that its nw corner coincides with the bottom center of the button
14.72.19.Modify the behaviour of the default JToolTip
14.72.20.Customizing a JToolTip Look and Feel