Creates a listener to restore the dismiss delay value for the the JTable tooltip. - Java Swing

Java examples for Swing:JTable

Description

Creates a listener to restore the dismiss delay value for the the JTable tooltip.

Demo Code


//package com.java2s;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JTable;

import javax.swing.ToolTipManager;

public class Main {
    /**//from w  w w. j ava 2 s  .c o m
     * Creates a listener to restore the dismiss delay value for the
     *   the table tooltip.
     * @param table The table.
     */
    public static void createToolTipDismissDelayListener(JTable table) {
        final int oldDelay = ToolTipManager.sharedInstance()
                .getDismissDelay();
        table.addMouseListener(new MouseAdapter() {
            public void mouseExited(MouseEvent e) {
                ToolTipManager.sharedInstance().setDismissDelay(oldDelay);
            }
        });
        table.setToolTipText(""); // Dummy to initialize the mechanism
    }
}

Related Tutorials