Example usage for javax.swing JToolTip addMouseListener

List of usage examples for javax.swing JToolTip addMouseListener

Introduction

In this page you can find the example usage for javax.swing JToolTip addMouseListener.

Prototype

public synchronized void addMouseListener(MouseListener l) 

Source Link

Document

Adds the specified mouse listener to receive mouse events from this component.

Usage

From source file:com.haulmont.cuba.desktop.sys.DesktopToolTipManager.java

protected void showTooltip(JComponent field, String text) {
    if (!field.isShowing())
        return;//www  .  j a va 2 s.c  o m

    if (StringUtils.isEmpty(text)) {
        return;
    }

    PointerInfo pointerInfo = MouseInfo.getPointerInfo();
    if (pointerInfo == null) {
        return;
    }

    if (toolTipWindow != null) {
        hideTooltip();
    }

    component = field;

    final JToolTip toolTip = new CubaToolTip();
    toolTip.setTipText(text);

    // Location to display tooltip
    Point location = getToolTipLocation(pointerInfo, toolTip.getTipText());

    final Popup tooltipContainer = PopupFactory.getSharedInstance().getPopup(field, toolTip, location.x,
            location.y);
    tooltipContainer.show();

    window = tooltipContainer;
    toolTipWindow = toolTip;

    tooltipShowing = true;
    if (!(field instanceof ToolTipButton)) {
        toolTip.addMouseListener(this);
        field.addMouseListener(this);
    }
}