RFR: 8348760: RadioButton is not shown if JRadioButtonMenuItem is rendered with ImageIcon in WindowsLookAndFeel [v30]
Alexey Ivanov
aivanov at openjdk.org
Mon Jun 30 13:23:45 UTC 2025
On Mon, 30 Jun 2025 13:01:49 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> 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
>
> As I said, I didn't look deeply into the details.
>
> The menu layout already implements a 5-column layout — this is what I expect because both Metal and Nimbus look exactly like a 5-column layout. Yet Windows L&F is still off, and the margins and offsets don't match what one sees in File Explorer in Windows 11.
After your latest fix, the accelerator doesn't get painted over the menu text, but the positioning is still way off.
With the added column for the icon the menu width has to increase but it hasn't. Instead, the width remains the same, and you squeeze both check mark / bullet and icon to the same allocated space.
The position of the check mark must not change in the new layout. In old rendering code, the was 29-pixel margin between the left edge and first pixel of the check mark (at 200% scale), but now it's reduced to 23 pixels only.
There was 24-pixel margin between an icon and text, but now it's only 6 pixels.
The margin between menu text and accelerator is reduced from 12 pixels to 4.
The menu looks too crowded, squished. You have to properly add *a new column for the icon* with margins around it whenever a popup menu has a JCheckBoxMenuItem or JRadioButtonMenuItem with an icon.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23324#discussion_r2175066908
More information about the client-libs-dev
mailing list