RFR: 8348760: RadioButton is not shown if JRadioButtonMenuItem is rendered with ImageIcon in WindowsLookAndFeel [v26]
Alexey Ivanov
aivanov at openjdk.org
Tue Jun 24 05:42:04 UTC 2025
On Thu, 19 Jun 2025 06:06:23 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
> > > In SwingSet2, now there will be gap between bullet and text to accomodate non-existing imageicon
> >
> >
> > That gap should only be there if _at least one_ menu item has an image icon. It shoudn't be there if none have an icon.
>
> That will require to find out if current menuItem is part of ButtonGroup and then reiterate each menuitems of the ButtonGroup and see if anyone has an imageicon..It does not seem possible to find out from current menuItem if it part of ButtonGroup as that info is not passed to each MenuItemUI (ButtonGroup info is only known to application/user)
Why? This depends on two factors only:
1. Are there any instances of `JCheckBoxMenuItem` or `JRadioButtonMenuItem`, and
2. Does any of them contain an icon?
If both are true, you add two columns for the *mark* and for the *icon*; in all other cases, the layout remains as it is now with one column where icons and marks are rendered.
The above is done in Metal L&F (run the test case in the default L&F), why can't it be done in Windows L&F?
> Also, assuming if we do find a way to get if this menuItem is part of a ButtonGroup, then iterating everytime to find out if any menu item has imageicon will affect performance. Probably it's better to reserve space for imageicon even if not present..
No, I don't think it's a good approach. Look at how it's done in Metal, ideally re-use the layout code.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23324#issuecomment-2987450656
More information about the client-libs-dev
mailing list