popups using JToolTip components did not respect their location (fixes #188; regression in 0.42 in fix for #164)

This commit is contained in:
Karl Tauber
2020-10-15 17:49:34 +02:00
parent ae445c9343
commit 8cef5ecf7e
2 changed files with 13 additions and 1 deletions

View File

@@ -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

View File

@@ -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