Example usage for java.awt PointerInfo getDevice

List of usage examples for java.awt PointerInfo getDevice

Introduction

In this page you can find the example usage for java.awt PointerInfo getDevice.

Prototype

public GraphicsDevice getDevice() 

Source Link

Document

Returns the GraphicsDevice where the mouse pointer was at the moment this PointerInfo was created.

Usage

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

protected Point getToolTipLocation(PointerInfo pointerInfo, String text) {
    Point mouseLocation = pointerInfo.getLocation();
    Rectangle bounds = getDeviceBounds(pointerInfo.getDevice());

    // Location on the current screen (suitable if there is more than one screen)
    Point currentScreenMouseLocation = getCurrentScreenMouseLocation(mouseLocation, bounds);

    // Location to display tooltip
    Point location = new Point(mouseLocation);

    Dimension dimension = DesktopComponentsHelper.measureHtmlText(text);

    location.x += getIndentation(bounds.width, dimension.width, currentScreenMouseLocation.x,
            DEFAULT_HORIZONTAL_INDENTATION);
    location.y += getIndentation(bounds.height, dimension.height, currentScreenMouseLocation.y,
            DEFAULT_VERTICAL_INDENTATION);

    return location;
}