diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a726d1b..8775ba4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ FlatLaf Change Log #### Fixed bugs - Custom window decorations: Not visible menu bar is now ignored in layout. +- Popups using `JToolTip` components did not respect their location. (issue + #188; regression in 0.42 in fix for #164) ## 0.43 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java index c1cae96b..bf1fcd24 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java @@ -218,7 +218,7 @@ public class FlatPopupFactory * and corrects the y-location so that the tooltip is placed above the mouse location. */ private Point fixToolTipLocation( Component owner, Component contents, int x, int y ) { - if( !(contents instanceof JToolTip) ) + if( !(contents instanceof JToolTip) || !wasInvokedFromToolTipManager() ) return null; Point mouseLocation = MouseInfo.getPointerInfo().getLocation(); @@ -233,6 +233,16 @@ public class FlatPopupFactory return new Point( x, mouseLocation.y - tipSize.height - UIScale.scale( 20 ) ); } + private boolean wasInvokedFromToolTipManager() { + StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); + for( StackTraceElement stackTraceElement : stackTrace ) { + if( "javax.swing.ToolTipManager".equals( stackTraceElement.getClassName() ) && + "showTipWindow".equals( stackTraceElement.getMethodName() ) ) + return true; + } + return false; + } + //---- class NonFlashingPopup --------------------------------------------- private class NonFlashingPopup