FlatLaf icon indicating copy to clipboard operation
FlatLaf copied to clipboard

ToolTip is refreshing multiple times when cursor is moving

Open yashwanththati5 opened this issue 1 year ago • 1 comments

Attaching a video for better understanding

https://github.com/JFormDesigner/FlatLaf/assets/58801238/90123a16-98de-40d9-97ae-81a0c2f5a316

Can we get any suggestions on how to fix this tooltip rendering issue in flatlaf , Thanks in advance.

yashwanththati5 avatar Apr 05 '24 06:04 yashwanththati5

Not sure what you're doing. By default, a tooltip does not follow the mouse location (as in the video). So you probably have some code that moves the tooltip, or re-creates tooltip at new location.

Please provide a self-contained test app that demonstrates the problem.

Also try disabling rounded border. Then maybe light-weight tooltips are used (when the tooltip fits into the frame).

UIManager.put( "ToolTip.borderCornerRadius", 0 );

DevCharly avatar Apr 07 '24 17:04 DevCharly

@mellmann has posted a test case to reproduce the issue here: https://github.com/JFormDesigner/FlatLaf/issues/672#issuecomment-2108909278

This is actually a general Swing problem and occurs as soon as "heavy weight" popups (based on JWindow) are used, which is always the case for FlatLaf to get nice borders with drop shadows from the operating system. Other Lafs use "light weight" popups (based on JPanel) when the tooltip fits into the containing window, but switch to "heavy weight" popups as soon as the tooltip is displayed (partly) outside of the window.

@mellmann you should see the same flickering tooltip in other Lafs when you move the mouse near the bottom or right window edge so that the tooltip is displayed outside of the test window.

Moving a popup/tooltip is only possible by hiding the old popup and showing a new popup at a new location (see javadoc of javax.swing.Popup).

Because "heavy weight" popups use a JWindow (a operating system window), which is continuously hidden and re-shown while the tooltip is moved, it flickers.

This is not easy to fix, but I have an idea how it could work... 😄

DevCharly avatar May 21 '24 09:05 DevCharly

Fixed in latest 3.5-SNAPSHOT: https://github.com/JFormDesigner/FlatLaf#snapshots

DevCharly avatar May 22 '24 12:05 DevCharly

@DevCharly thanks for the quick reaction! I'm looking forward to trying out the fix in the next few days.

I'm not sure if it's helpful but, I noticed that the delays only appear with the native libraries. If the native library is deactivated then everything is fast (of course, some modern decorations like the round corners disappear as well).

System.setProperty( "flatlaf.useNativeLibrary", "false" );

mellmann avatar May 23 '24 07:05 mellmann

I'm not sure if it's helpful but, I noticed that the delays only appear with the native libraries. If the native library is deactivated then everything is fast (of course, some modern decorations like the round corners disappear as well).

Yes, but only on Windows and only as long as the tooltip fits into the containing windows. On macOS and Linux, FlatLaf always uses "heavy weight" popups.

DevCharly avatar May 23 '24 09:05 DevCharly