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

Prasanta Sadhukhan psadhukhan at openjdk.org
Tue Feb 17 11:46:10 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" />

> I don't have review permissions, but I'd like to comment on something that caught my eye.
> 
> The following image is a screenshot of the test `test/jdk/javax/swing/JMenuItem/TestRadioAndCheckMenuItemWithIcon.java` that was added by [JDK-8348760](https://bugs.openjdk.org/browse/JDK-8348760).
> 
> Before <img alt="before" width="250" height="248" src="https://private-user-images.githubusercontent.com/146925119/550911585-51c44938-bf61-44f0-a6fe-f5cf6b05a2c3.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzEzMjg2NTUsIm5iZiI6MTc3MTMyODM1NSwicGF0aCI6Ii8xNDY5MjUxMTkvNTUwOTExNTg1LTUxYzQ0OTM4LWJmNjEtNDRmMC1hNmZlLWY1Y2Y2YjA1YTJjMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMjE3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDIxN1QxMTM5MTVaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01OTFhNWU1NzU0MjMwNTBmZGMwZTY2YjdhYWM3ODRjNmUyNTFiNjM1Y2U1MWUzMGE2ODNiYTE5YjNlOGI4NTEzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.JVknLnmwMeCEXFBeTx66ucfslNJKAZ6e5Clx7D-mDyc">
> 
> After <img alt="after" width="248" height="247" src="https://private-user-images.githubusercontent.com/146925119/550911838-b5d01603-3bc7-4f4b-a538-20fcb13e74d9.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzEzMjg2NTUsIm5iZiI6MTc3MTMyODM1NSwicGF0aCI6Ii8xNDY5MjUxMTkvNTUwOTExODM4LWI1ZDAxNjAzLTNiYzctNGY0Yi1hNTM4LTIwZmNiMTNlNzRkOS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMjE3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDIxN1QxMTM5MTVaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yMTIwZWI1M2E2NGIxZWU3MjM1OTVjNmRiMTU5NDY2M2UxOTAzMmU2OTgwMGMyNmQ2MjljYmViZDg1ZWYxMTEwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.uskBGN3tWshAur6s2yO6doqTGGMVYLCJ37DlFW9s820">
> 
> Before this change, the left edges of all the red squares are aligned, and the text of each menu item is also left-aligned. However, after this change, for menu items without radio buttons or checkboxes, the red squares and the text are misaligned compared to the others. Is this an expected behavioral change introduced by this fix?

I dont think we can align normal JMenuItem icon location with JRadioButtonMenuItem/JCheckBoxMenuItem icon location.
The latter needs a two column layout while normal JMenuItem as in this case needs 1 column as was asked in this JBS so the icon is left aligned for normal JMenuItem so it's expected change as far I am concerned.

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

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


More information about the client-libs-dev mailing list