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

Prasanta Sadhukhan psadhukhan at openjdk.org
Tue Feb 4 13:18:30 UTC 2025


On Tue, 4 Feb 2025 12:24:24 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> But that's what I believe is been done now in the PR test, corresponding to your 1st image and corresponds to windows11
>> 
>> ![image](https://github.com/user-attachments/assets/2ddab37a-0513-4e08-8df9-9a3a2a054b8b)
>> 
>> If icon is present, it will be drawn at x+3*OFFSET...and button/checkmark is always drawn at x-OFFSET irrespective of icon
>>  present or not..
>> Are you suggesting to keep more gap in between checkmark and button?
>
>> But that's what I believe is been done now in the PR test, corresponding to your 1st image and corresponds to windows11
> 
> No, it doesn't.
> 
> On Windows 10 which has a selected background around the bullet, it looks completely off.
> 
> ![radio-menuitem-with-icon-01-2025-02-04](https://github.com/user-attachments/assets/6a0dd6b6-c611-4fc7-9f25-5125c539fa5b)
> 
> ![radio-menuitem-with-icon-02-2025-02-04](https://github.com/user-attachments/assets/1e5a7540-d74e-4a5a-b338-2f04a5076c9d)
> 
> [The original behaviour](https://github.com/openjdk/jdk/pull/23324#issuecomment-2624726843) was consistent at least.
> 
> Yet what the currently proposed fix produces doesn't look right at all.
> 
> The bullet or check-mark should remain centered in their own place as if there's no icon.
> 
>> Are you suggesting to keep more gap in between checkmark and button?
> 
> Yes, but not only.
> 
> If there's an icon, it should move the text to the right to accommodate the additional icon, if we're going this route.
> 
> In addition to that, the text in all other menu items should move to the right for consistency so that all the menu items are aligned and items without an icon render an empty icon in this case.
> 
> We may introduce a property that controls this behaviour: whether the text aligns in all the menu items or not.
> 
> The first option corresponds to this layout:  
> ![Proposed layout - aligned text](https://github.com/user-attachments/assets/60ef0c8c-544c-44fd-8e7a-a0a52254f9b6)  
> where all the text moves right to add space for menu icons. This corresponds to menu layout in File Explorer in Windows 11.
> 
> The second option corresponds to this layout:  
> ![Proposed layout - unaligned text](https://github.com/user-attachments/assets/7ee4a124-ed16-4606-b325-d9dafc96d4d8)  
> where the second menu item remains at the position where it's rendered now.

I have modified the PR to move the icon w.r.t bullet skin width and it looks like this in windows 11..I believe this should work for windows 10 also but I dont have windows10 to check

![image](https://github.com/user-attachments/assets/953eee76-ee88-4189-9ed8-681854c27363)


I dont think we can tamper with text location as it is done in WindowsMenuItemUI#paintText which does not have any knowledge of bullet/icon presence.
Also, ideally I dont think this should be applicable for windows10 and we should do this only for windows11 but I am not sure if there is version check in our code and anyway, windows10 would be EOL-ed and unsupported platform in few months

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

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


More information about the client-libs-dev mailing list