We use cookies to collect and analyze information on site performance and usage,
to provide social media features and to enhance and customize content and advertisements.
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();
}
}