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

        // Set a tool tip for a Quit button.
        // Make the delay relatively short before tips are shown.
class SwingToolTipFrame extends JFrame {
    public SwingToolTipFrame() {
        final int width = 300, height = 100;
        setSize(width,height);
        Container contents = getContentPane();

        JButton quit = new JButton("Quit");
        quit.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                System.exit(0);
            }
        });

        // Set a small delay (in milliseconds) before tips are shown.
        ToolTipManager manager = ToolTipManager.sharedInstance();
        manager.setInitialDelay(250);
        // Set the tool tip for the quit button.
        quit.setToolTipText("Quit the program");

        JPanel buttonPanel = new JPanel();
        buttonPanel.add(quit);
        contents.add(buttonPanel,"South");
    }
}
