Disable / enable application tool tips : Tooltip « Swing JFC « Java






Disable / enable application tool tips

   
 
import java.awt.FlowLayout;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.ToolTipManager;

public class Main extends JFrame {
  public Main() throws HeadlessException {
    setSize(300, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));

    JButton disable = new JButton("DISABLE");
    disable.setToolTipText("disabled.");
    disable.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        ToolTipManager.sharedInstance().setEnabled(false);
      }
    });
    JButton enable = new JButton("ENABLE");
    enable.setToolTipText("enabled.");
    enable.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        ToolTipManager.sharedInstance().setEnabled(true);
      }
    });
    getContentPane().add(enable);
    getContentPane().add(disable);
  }

  public static void main(String[] args) {
    new Main().setVisible(true);
  }
}

   
    
    
  








Related examples in the same category

1.Tooltip SampleTooltip Sample
2.Html tooltipsHtml tooltips
3.Working with Tooltip TextWorking with Tooltip Text
4.MultiLine ToolTip ExampleMultiLine ToolTip Example
5.Colored ToolTip ExampleColored ToolTip Example
6.Making Tool Tips Remain Visible
7.Enabling and Disabling Tool Tips
8.Making Tool Tips Appear Immediately
9.Use the default tool tip location
10.Make a tool tips appear immediately
11.Showing an Image in a Tool Tip with HTML
12.Setting a Tool Tip
13.Setting the Location of a Tool Tip
14.By default, the lines are left justified. Center the lines.
15.Set the location of the tool tip such that its nw corner coincides with the bottom center of the button
16.Showing an Image in a ToolTip
17.Modify the behaviour of the default JToolTip
18.Italicize the second line
19.Changing ToolTip background color for Swing Applications
20.ToolTip Location ExampleToolTip Location Example
21.Set a tool tip for swing component
22.JToolTip With Icon