RFR: 8370945: With Windows LAF, the location of a JMenuItem icon is incorrect

Prasanta Sadhukhan psadhukhan at openjdk.org
Wed Feb 18 07:17:21 UTC 2026


On Mon, 16 Feb 2026 01:30:06 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> [JDK-8348760](https://bugs.openjdk.org/browse/JDK-8348760) fixed an issue in Windows L&F JMenuItem layout whereby radio bullet/checkmark was rendered in different columnspace than menuitem imageicon so radiobullet/checkmark is rendered in first column and imageicon is rendered in 2nd column but this rendering of imageicon in 2nd columnspace was done invariably for all JMenuItem irrespective of if it is JRadioButtonMenuItem or JCheckBoxMenuItem or JMenuItem, which is wrong.
> 
> Normal JMenuItem (which are not JRadioButtonMenuItem or JCheckBoxMenuItem) imageicon rendering should be done in first columnspace as was done before JDK-8348760 fix because there is no radiobullet/checkmark to render for those menuitems so no need to reserve columnspace for those bullet/checkmark icon
> 
> Before fix
> 
> <img width="205" height="127" alt="image" src="https://github.com/user-attachments/assets/13a1e352-5e8d-4251-b7a7-032935eab74e" />
> 
> 
> After fix
> 
> <img width="195" height="131" alt="image" src="https://github.com/user-attachments/assets/84ec3ee6-2823-4bf7-840d-b53f2e9d44c3" />

Metal and Nimbus are platform independent so they can do their own things but Windows L&F need to do similar to what native application does, if not in pixel-perfect way, but atleast in essence, and as mentioned in JBS and seen in windows app, normal menu item icon is aligned to left edge as seen below

<img width="387" height="179" alt="image" src="https://github.com/user-attachments/assets/574fe54e-4328-463e-a6df-ef337f7f8cfb" />

and
<img width="331" height="449" alt="image" src="https://github.com/user-attachments/assets/606d15ae-294a-4ce1-9ae0-a962564f21d4" />

I couldn't find any native app view that will have radiobutton, checkmark and normal menuitem along with imageicon as is tested in `test/jdk/javax/swing/JMenuItem/TestRadioAndCheckMenuItemWithIcon.java` but I think it will behave in same way as it is doing in current PR
This is the closest I could find with checkmark and menuitem icon but it does not have image icon along with checkmark but as we can see menuitem icon is left+vertical aligned with checkmark (as we have as seen in https://github.com/openjdk/jdk/pull/29730#issuecomment-3913870880)
<img width="270" height="393" alt="image" src="https://github.com/user-attachments/assets/49784a32-736e-4189-a0ad-dae0709b726b" />

However, if one feels the layouting is wrong and needs to be changed, one can also propose own PR but I think it is fine from my perspective as it is now..

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

PR Comment: https://git.openjdk.org/jdk/pull/29730#issuecomment-3919123593


More information about the client-libs-dev mailing list