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

Alexey Ivanov aivanov at openjdk.org
Thu Jun 26 13:58:34 UTC 2025


On Thu, 26 Jun 2025 12:32:42 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> > > Current PR doesnt have this..Text string is not aligned for item that doesn't have iconimage with item that does have iconimage. I will fix this.
> > 
> > 
> > This still remain unresolved: the text of all menu items should be aligned.
> 
> It is fixed for RBMIs as they are part of ButtonGroup (where selecting one will deselect other) so we can find out if any of the RBMIs in that group has imageicon by obtaining ButtonGroup object.

Why is it important?

> CBMIs are not part of group and can be selected/deselected individually so it doesn't seem possible to know from one CBMI whether another CBMI used by application have imageicon or not (similar for regular MIs) so in their case text are aligned individually depending on presence of imageicon for that CBMI (or regular MI)

Why is it important?

[The rule](https://github.com/openjdk/jdk/pull/23324#issuecomment-3005416654) to switching to two-column layout is as simple as that:

> *There's a least one `JCheckBoxMenuItem` and/or `JRadioButtonMenuItem` that has an icon.*

If there's at least one `JCheckBoxMenuItem` and/or `JRadioButtonMenuItem` in a popup menu, the entire menu should be laid out in two columns reserved columns:

* The first column is for check mark or bullet;
* The second column is for the icon associated with a menu item;
* The text goes in the third column;
* Accelerators are rendered in the fourth column.

This is absolutely possible, both Metal & Nimbus L&F use this menu layout.\
![JMenu layout with radio bullets, check marks and icons in Metal Look-and-Feel](https://github.com/user-attachments/assets/65c5b4bb-dc3b-46dd-a74a-2cb6ef53ccc9) ![JMenu layout with radio bullets, check marks and icons in Nimbus Look-and-Feel](https://github.com/user-attachments/assets/b79ce261-9602-42c4-b3cd-c3686b3cc932)

If none of `JCheckBoxMenuItem` and `JRadioButtonMenuItem` has an icon, both check marks / bullets and icons share the same first column.

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

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


More information about the client-libs-dev mailing list