On Tue, 24 Jun 2025 05:42:04 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> 
wrote:

>> When JRadioButtonMenuItem is called with imageIcon, then only imageIcon is 
>> shown without radiobutton in WIndowsLookAndFeel as there was no provision of 
>> drawing the radiobutton alongside icon.
>> If icon is not there, the radiobutton is drawn. Added provision of drawing 
>> the radiobutton windows Skin even when imageIcon is present.
>
> Prasanta Sadhukhan has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Fix issue for presence of gap between buller and text only if atleast 1 
> menuitem has imageicon

The current layout doesn't match the layout of menus in Windows.

The check mark or the bullet has to be painted where it was always painted. The 
menu in Windows 10 looks broken now:

![The position of the check mark isn't in the centre of the 
highlight](https://github.com/user-attachments/assets/5fecfb30-171d-4273-9d4a-234bc07edfaf)

This applies to the radio bullet JRadioButtonMenuItem3 which has no icon.

In Windows 11, I expect the check mark and the bullet render at the same 
location as it was before the fix, but it's not the case.

Below is a portion of the menu rendered with the current fix:

![Comparison of JMenuItem on Windows11 with the fix vs. without the 
fix](https://github.com/user-attachments/assets/df1d5262-94af-4efb-9625-69c96653d45a)

The part on the image in an orange rectangle is a portion of the same test case 
running on JDK that has no fix.

1. The width of the popup menu with the two columns—for check marks or bullets 
and icons—is the same, how is it possible? If a second column for the icon is 
added, the width of the popup menu has to increase.
2. The text of `JCheckBoxMenuItem 3` is not aligned to other menu items text.\
  This applies to any other item added to the menu: *the text of all items must 
align*.
4. The location of the check mark and the bullet is wrong, you moved the check 
mark / bullet to the left but now it doesn't match the menu layout of a native 
Win32 application.
5. If I add another regular menu item with an icon, the icon is rendered below 
the menu item text.

We have to support two cases:

1. One column is reserved as it is currently done;
2. Two columns are reserved if there's `JCheckBoxMenuItem` and/or 
`JRadioButtonMenuItem` that has an icon.

To reiterate [Phil's 
suggestion](https://github.com/openjdk/jdk/pull/23324#issuecomment-2914400828),

* **One-column layout** (nothing changes):
  * No menu item has icons, check marks or bullets;
  * There are `JCheckBoxMenuItem` and/or `JRadioButtonMenuItem` but they have 
no icons, and no other menu items have icons either;
  * There are `JCheckBoxMenuItem` and/or `JRadioButtonMenuItem` but none of 
them has an icon, yet there are other menu items with icons: the check marks / 
bullets and the icons share the same reserved column.
* **Two-column layout** (new layout):
  * There's a least one `JCheckBoxMenuItem` and/or `JRadioButtonMenuItem` that 
has an icon.

In the two-column layout, the first column (which is always present) is 
reserved for check marks and bullets of `JCheckBoxMenuItem` and 
`JRadioButtonMenuItem` correspondingly, and the second column is reserved for 
rendering any icons that menu items have.

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

PR Comment: https://git.openjdk.org/jdk/pull/23324#issuecomment-3005372591
PR Comment: https://git.openjdk.org/jdk/pull/23324#issuecomment-3005416654

Reply via email to