RFR: 6223700: XP L&F: Non-TopLevel JMenu's painting error
Alexander Zuev
kizune at openjdk.org
Wed Dec 3 21:43:25 UTC 2025
On Fri, 28 Nov 2025 08:50:09 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
> It is seen that non-TopLevel JMenu's get repainted when the mouse exits the item. If the popup menu is still visible to the right, repainting the JMenu causes the selection background to be repainted over the top of the popup, even though the popup is supposed to appear above the JMenu.
>
> The problem is caused by the mouse handling code in the protected inner class `WindowsMenuUI.WindowsMouseInputHandler.` The `mouseEntered` and `mouseExited` handlers set the RollOver property and the JMenu gets repainted. However, setting the RollOver property is only necessary for top-level JMenus. Non-TopLevel JMenu menu items such as these get painted by the super class BasicMenuItemUI which uses isSelected() rather than isRollOver() to determine whether the selection background color should be used.
>
> Fix is to use the repainting only for TopLevel Menu in `mouseExited`, the same way it is being done for `mouseEntered`
LGTM
-------------
Marked as reviewed by kizune (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/28551#pullrequestreview-3537041554
More information about the client-libs-dev
mailing list