String tooltipText = component.getTooltipText();
// The tooltip text may have been cleared while the timeout was
// outstanding; if so, don't display the tooltip
if (tooltipText != null) {
Tooltip tooltip = new Tooltip(tooltipText);
Point location = component.getDisplay().getMouseLocation();
int x = location.x;
int y = location.y;
// Ensure that the tooltip stays on screen
Display display = component.getDisplay();
int tooltipHeight = tooltip.getPreferredHeight();
if (y + tooltipHeight > display.getHeight()) {
y -= tooltipHeight;
}
tooltip.setLocation(x + 16, y);
tooltip.open(component.getWindow());
}
}