Keep a JTooltip visibleTag(s): Swing


import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class TooltipInSwing extends JFrame {
 public TooltipInSwing() {
        super("TooltipInSwing");
        setSize(400, 300);
        getContentPane().setLayout(new FlowLayout());

        JButton b1 = new JButton("Simple tooltip 1");
        b1.setToolTipText("simple tool tip without a dismiss delay");

        // set a new dismiss delay to a really big value, default is 4 sec.
        ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE);

        getContentPane().add(b1);

        WindowListener wndCloser = new WindowAdapter(){
            public void windowClosing(WindowEvent e) {
                System.exit(0);
                }
            };
        addWindowListener(wndCloser);
        setVisible(true);
    }

    public static void main(String args[]){
     new TooltipInSwing();
     }
}

blog comments powered by Disqus