RFR: 8373650: Test "javax/swing/JMenuItem/6458123/ManualBug6458123.java" fails because the check icons are not aligned properly as expected [v2]

Prasanta Sadhukhan psadhukhan at openjdk.org
Fri Jan 16 04:03:59 UTC 2026


On Thu, 15 Jan 2026 12:29:59 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

> Is it because Windows icons used to be special and combined the icon and check mark / bullet mark, or rather replaced the check mark / bullet mark with the icon? Should we get rid of that special treatment?

I am reusing the VistaMenuItemCheckIcon to render the RadioButtonMenuItem and CheckBoxMenuItem icons and getting rid of the working/treatment made in that class (and rewriting) might result in more regressions which I am avoiding..
There are many factors apart from normal that is affecting the icon position like `menuItem.setHorizontalTextPosition(LEADING/TRAILING/LEFT/RIGHT etc)`, `menuItem.setHorizontalTextPosition(RIGHT/CENTER etc)`  which can cause issues like what we are seeing in https://github.com/openjdk/jdk/pull/28210 which atleast is working now for Windows L&F without any rework.
Metal L&F seems to hardcode the icon position to (0,0) or (2,2) 
https://github.com/openjdk/jdk/blob/e4474ad8ae250771e031b8c18809d3e461970365/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalIconFactory.java#L2268-L2302
whereas I am reusing the methodology in VistaMenuItemIcon using OFFSET and it seems to work for cases seen till now..

>> it is taken care via ternary operator, width/spread of check mark is usually more than radio bullet so starting point of checkmark is considered a little ahead compared to radio bullet
>
> I see that it's taken care by the ternary operator. Why is it needed, though?
> 
> The skin for both check mark and radio bullet have the same size, and the mark is positioned accordingly inside the rectangle. This works well for the LTR layout, both marks are rendered at the same location and appear aligned in the end. Why does RTL layout treat these marks differently?

As told and code shown earlier, the RTL oversees overall rectangle width using all text rect, image icon rect, icon rect etc to calculate icon x position unlike LTR and it seemed a bit off for checkmark as compared to bullet by 1 or 2 pixel or so  I catered to it by this logic

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28889#discussion_r2696785303
PR Review Comment: https://git.openjdk.org/jdk/pull/28889#discussion_r2696788855


More information about the client-libs-dev mailing list