On Fri, 12 Jun 2026 03:06:49 GMT, Prasanta Sadhukhan <[email protected]> 
wrote:

>> [JDK-8348760](https://bugs.openjdk.org/browse/JDK-8348760) fixed an issue in 
>> Windows L&F JMenuItem layout whereby radio bullet/checkmark was rendered in 
>> different columnspace than menuitem imageicon so radiobullet/checkmark is 
>> rendered in first column and imageicon is rendered in 2nd column but this 
>> rendering of imageicon in 2nd columnspace was done invariably for all 
>> JMenuItem irrespective of if it is JRadioButtonMenuItem or JCheckBoxMenuItem 
>> or JMenuItem, which is wrong.
>> 
>> Normal JMenuItem (which are not JRadioButtonMenuItem or JCheckBoxMenuItem) 
>> imageicon rendering should be done in first columnspace as was done before 
>> JDK-8348760 fix because there is no radiobullet/checkmark to render for 
>> those menuitems so no need to reserve columnspace for those bullet/checkmark 
>> icon
>> 
>> Before fix
>> 
>> <img width="205" height="127" alt="image" 
>> src="https://github.com/user-attachments/assets/13a1e352-5e8d-4251-b7a7-032935eab74e";
>>  />
>> 
>> 
>> After fix
>> 
>> <img width="195" height="131" alt="image" 
>> src="https://github.com/user-attachments/assets/84ec3ee6-2823-4bf7-840d-b53f2e9d44c3";
>>  />
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Prasanta Sadhukhan has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Review comment

Changes requested by aivanov (Reviewer).

src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java
 line 910:

> 908:                         XPStyle xp = XPStyle.getXP();
> 909:                         if (xp != null) {
> 910:                             Skin skin =  xp.getSkin(c, backgroundPart);

Suggestion:

                            Skin skin = xp.getSkin(c, backgroundPart);

The space was present in the older code, but it doesn't need to be here.

src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java
 line 911:

> 909:                         if (xp != null) {
> 910:                             Skin skin =  xp.getSkin(c, backgroundPart);
> 911:                             skin.paintSkin(g, x, y, backgroundState);

The old code painted the skin for the entire icon.


                            skin.paintSkin(g, x, y,
                                getIconWidth(), getIconHeight(), 
backgroundState);

Now the skin background is painted in a small area in the left top corner.

<img width="216" height="140" alt="Screenshot that shows the visual styles 
background isn't painted as it should: it's only in small area instead of 
around the radio bullet" 
src="https://github.com/user-attachments/assets/aac9c439-ccea-4bc9-9890-756249549333";
 />

src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java
 line 187:

> 185:     }
> 186: 
> 187:     public static class MenuScanResult {

Suggestion:

    public static final class MenuScanResult {

The result isn't intended to be extended, then mark it `final`.

Does the class need to be `public`?

src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java
 line 220:

> 218:         if (size != null) {
> 219: 
> 220:             if (hasCheckBulletAndIconPresent((JPopupMenu) c)) {

The blank line between these two `if` statements seems redundant.

To reduce indentation, you could even merge the two conditions into one relying 
on short-circuit evaluation.

src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java
 line 243:

> 241:                     return true;
> 242:                 }
> 243:             }

Why does the presence of check marks / bullets and icons in a submenu affect 
rendering of the current popup?

Each drop-down menu from the menu bar and each submenu should be independent.

Otherwise, it makes the first popup too wide for no reason:

<img width="312" height="166" alt="The first drop-down reserves the space for 
the icon column but no icon is present in its menu items — but a submenu has 
displays both a check mark and an icon" 
src="https://github.com/user-attachments/assets/4d9357fc-cabc-41f7-a6cc-d97cd62fddb0";
 />

Also notice that the selection of the submenu is painted over the owned popup.

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

PR Review: https://git.openjdk.org/jdk/pull/29730#pullrequestreview-4831029615
PR Review Comment: https://git.openjdk.org/jdk/pull/29730#discussion_r3692542878
PR Review Comment: https://git.openjdk.org/jdk/pull/29730#discussion_r3692643334
PR Review Comment: https://git.openjdk.org/jdk/pull/29730#discussion_r3692650164
PR Review Comment: https://git.openjdk.org/jdk/pull/29730#discussion_r3692686580
PR Review Comment: https://git.openjdk.org/jdk/pull/29730#discussion_r3692429304

Reply via email to