RFR: 8348760: RadioButton is not shown if JRadioButtonMenuItem is rendered with ImageIcon in WindowsLookAndFeel [v30]

Prasanta Sadhukhan psadhukhan at openjdk.org
Mon Jun 30 02:19:49 UTC 2025


On Fri, 27 Jun 2025 11:44:01 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Have you checked this code? It doesn't work for me
>> 
>> I get this whereby JRadioButtonMenuItem3 which doesnt have imageicon is not aligned..For this only, we need to know if other RBMIs have imageicon from ButtonGroup or if there any other way, let me know..
>> 
>> ![image](https://github.com/user-attachments/assets/eb2d701e-f235-4527-9f80-e372586fc16a)
>
> No, I didn't.
> 
> It doesn't work because the overall menu layout isn't right at the moment. If you implement [four-column layout](https://github.com/openjdk/jdk/pull/23324#issuecomment-3008593168): check mark / bullet, icon, text, accelerator, it would work. Just like the text of **MenuItem1** and **JCheckBoxMenuItem 3** would be aligned to the text of other menu items.

Probably you missed seeing it but already _5-column layout_ is implemented via [MenuItemLayoutHelper.layoutMenuItem.](https://github.com/openjdk/jdk/blob/ecd2d83096a1fea7d5086736306770bcffa4fdb6/src/java.desktop/share/classes/sun/swing/MenuItemLayoutHelper.java#L464-L476)
 In the PR. `WindowsMenuItemUI.paintMenuItem` calls `MenuItemLayoutHelper.layoutMenuItem` to layout in 5 columns actually through
check icon + icon + text + accelerator text + arrow icon layout
via `paintCheckIcon, paintIcon, paintText, paintAccText and paintArrowIcon` call in `WindowsMenuItemUI.paintMenuItem` 

seems like offset value used in WindowsIconFactory paintIcon is not matching with MenuItemLayout expectation and wrong rendering is happening at slightly off position

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23324#discussion_r2174089015


More information about the client-libs-dev mailing list