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

Alexey Ivanov aivanov at openjdk.org
Fri Feb 7 19:23:15 UTC 2025


On Fri, 7 Feb 2025 05:26:10 GMT, Prasanta Sadhukhan <psadhukhan at 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 two additional commits since the last revision:
> 
>  - remove test file
>  - Move text position w.r.t menuItem icon

Changes requested by aivanov (Reviewer).

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java line 662:

> 660:         paintCheckIcon(g, lh, lr, holdc, foreground);
> 661:         paintIcon(g, lh, lr, holdc);
> 662:         if (UIManager.getLookAndFeel().getName().equals("Windows")

Can't this be handled in `WindowsMenuItemUI` instead? After all, Metal and Windows L&F looked differently.

test/jdk/javax/swing/JMenuItem/TestImageIconWithJRadioButtonMenuItemAndJCheckBoxMenuItem.java line 1:

> 1: /*

Does it have to be that long? `TestRadioAndCheckMenuItemWithIcon.java` looks descriptive enough.

test/jdk/javax/swing/JMenuItem/TestImageIconWithJRadioButtonMenuItemAndJCheckBoxMenuItem.java line 118:

> 116:         buttonGroup1.add(check1);
> 117:         buttonGroup1.add(check2);
> 118:         buttonGroup1.add(check3);

I expect that each check-box can be selected independently from others.

test/jdk/javax/swing/JMenuItem/TestImageIconWithJRadioButtonMenuItemAndJCheckBoxMenuItem.java line 137:

> 135:         frame.setJMenuBar(menuBar);
> 136:         frame.setSize(300, 300);
> 137:         frame.setLocationRelativeTo(null);

`setLocationRelativeTo` is redundant, the location of the frame is controlled by `PassFailJFrame`.

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

PR Review: https://git.openjdk.org/jdk/pull/23324#pullrequestreview-2602598579
PR Review Comment: https://git.openjdk.org/jdk/pull/23324#discussion_r1947041075
PR Review Comment: https://git.openjdk.org/jdk/pull/23324#discussion_r1947049448
PR Review Comment: https://git.openjdk.org/jdk/pull/23324#discussion_r1947056340
PR Review Comment: https://git.openjdk.org/jdk/pull/23324#discussion_r1947057458


More information about the client-libs-dev mailing list