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

Daishi Tabata dtabata at openjdk.org
Thu Feb 19 10:45:36 UTC 2026


On Thu, 19 Feb 2026 03:34:55 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" />
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix

The native app menu (where ImageIcon and check are on the same row), as described in https://github.com/openjdk/jdk/pull/29730#issuecomment-3919123593 looks like this:

<img width="213" height="214" alt="good" src="https://github.com/user-attachments/assets/32cc8f63-5c77-4831-ad7f-4b324af63429" />

This is rendered correctly (thanks to this fix).
However, we haven’t found a native app menu that corresponds to `test/jdk/javax/swing/JMenuItem/TestRadioAndCheckMenuItemWithIcon.java`, so I'm not sure the following claim holds:

> kept the JMenuItem imageicon alignment as it seems to be at par with native app for normal non-radio/non-check JMenuItem (as mentioned here #29730 (comment))

Also, in Nimbus and Metal, the square is left-aligned:

Numbus
<img width="271" height="217" alt="numbus" src="https://github.com/user-attachments/assets/4a5f7148-510e-4106-9533-f49cf5a83a25" />

Metal
<img width="241" height="218" alt="metal" src="https://github.com/user-attachments/assets/ddbfa109-fb8c-48ae-b12a-bd56e8c4d876" />

If the alignment in Windows LAF and Nimbus (or Metal) is required to be the same, then this fix is still not sufficient.
However, I don’t actually know whether they are required to match. Because of that, although it feels a bit unintuitive to me, I’m not sure what the correct behavior should be.

I’m sorry that I can only point this out without being able to provide a clear suggestion.

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

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


More information about the client-libs-dev mailing list