diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java index df9bf3ca..4347fc6e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java @@ -43,6 +43,18 @@ import java.beans.PropertyChangeListener; public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListener, HierarchyListener { protected JToolTip toolTip; + protected MouseListener exitListener = new MouseAdapter() { + @Override + public void mouseExited(final MouseEvent e) { + boolean inside = isInside(e); + if (!inside) { + ToolTipManager.sharedInstance().mouseExited( + new MouseEvent(toolTip.getComponent(), e.getID(), e.getWhen(), e.getModifiersEx(), + Integer.MIN_VALUE, Integer.MIN_VALUE, e.getClickCount(), e.isPopupTrigger(), + e.getButton())); + } + } + }; protected MouseListener mouseListener = new MouseAdapter() { @Override public void mouseEntered(final MouseEvent e) { @@ -66,22 +78,7 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe @Override public void mouseExited(final MouseEvent e) { - boolean inside = isInside(e); - if (!inside) { - ToolTipManager.sharedInstance().mouseExited( - new MouseEvent(toolTip.getComponent(), e.getID(), e.getWhen(), e.getModifiersEx(), - Integer.MIN_VALUE, Integer.MIN_VALUE, e.getClickCount(), e.isPopupTrigger(), - e.getButton())); - } - } - }; - protected MouseListener exitListener = new MouseAdapter() { - @Override - public void mouseExited(final MouseEvent e) { - ToolTipManager.sharedInstance().mouseExited( - new MouseEvent(toolTip.getComponent(), e.getID(), e.getWhen(), e.getModifiersEx(), - Integer.MIN_VALUE, Integer.MIN_VALUE, e.getClickCount(), e.isPopupTrigger(), - e.getButton())); + exitListener.mouseExited(e); } }; @@ -95,8 +92,14 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe } protected boolean isInside(final MouseEvent e) { - Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), toolTip); - return contains(toolTip, p.x, p.y); + Point screenPos = e.getPoint(); + SwingUtilities.convertPointToScreen(screenPos, e.getComponent()); + Point toolTipPoint = new Point(screenPos.x, screenPos.y); + Point compPoint = new Point(screenPos.x, screenPos.y); + SwingUtilities.convertPointFromScreen(toolTipPoint, toolTip); + SwingUtilities.convertPointFromScreen(compPoint, toolTip.getComponent()); + return toolTip.getComponent().contains(compPoint) + || contains(toolTip, toolTipPoint.x, toolTipPoint.y); } @Override