On Thu, 15 Oct 2026 06:55:22 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 fix The updated version looks much better: it makes the popup wider when it needs to allocate the second column for rendering the icon, therefore I'm approving this PR. Yet there are still a few inconsistencies compared to how Win32 renders menus. The highlight of the selected mark is 22 pixels, all good. But the icon in the second column has no margin, it's rendered at the next pixel. <img width="215" height="53" alt="two menu items" src="https://github.com/user-attachments/assets/8b3830e7-7bd8-435e-914b-88c4aacca4b7" /> There should be 3-pixel margin between the highlight and the rendered icon. I measured it using the Win32 app that was posted here. When a menu item has a mark and an icon, both are highlighted. <img width="137" height="58" alt="highlight around icon" src="https://github.com/user-attachments/assets/6ff56462-c407-4d85-903f-39ef5a30a13e" /> There's no way to see how Win32 renders this. In that same Win32 app, when the item with a custom checkmark bitmap is selected, Windows doesn't paint highlight around it at all. There are two options: highlight only the mark or both. I have a slight preference for the former. At the same time, this detail isn't visible on Windows 11. Windows leaves 11 pixels between the mark highlight and text, adding 3-pixel margin around the icon. When the item is not selected, there's 14 pixels between the icon edge and text. This fix leaves only 12 pixels. When both the mark and the icon are highlighted for a selected menu item, the margin between the highlight and menu text is 10 pixels. (The highlight has the expected 3-pixel margin from the icon edge.) I didn't measure the margins for accelerators, submenu arrow indicator… src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java line 929: > 927: } > 928: } > 929: private int getImageOffset() { Suggestion: } private int getImageOffset() { Add a blank line between methods. test/jdk/javax/swing/JMenuItem/TestRadioAndCheckMenuItemWithIcon.java line 25: > 23: > 24: /* > 25: * @test id=default Suggestion: * @test id=system Be consistent: use the same id that you pass as the parameter. test/jdk/javax/swing/JMenuItem/TestRadioAndCheckMenuItemWithIcon.java line 87: > 85: <ul> > 86: <li> > 87: A window is displayed which has 2 Menu on the menu bar. Suggestion: A window is displayed which has two menus on the menu bar. test/jdk/javax/swing/JMenuItem/TestRadioAndCheckMenuItemWithIcon.java line 98: > 96: </li> > 97: <br> > 98: <li> `<br>` between `<li>` is an invalid HTML. Both `<ul>` and `<ol>` allow only `<li>` elements. [Reference](https://html.spec.whatwg.org/multipage/grouping-content.html#the-ul-element): > The ul element\ > Content model:\ > Zero or more `li` elements. You should use `<li style="margin-top: 1em">` to add additional margin or put `<br>` inside `<li>`. test/jdk/javax/swing/JMenuItem/TestRadioAndCheckMenuItemWithIcon.java line 105: > 103: <br>First checkbox menuitem is selected with image icon. > 104: <br>Second checkbox menuitem is unselected with image > icon. > 105: <br>Third checkbox menuItem is unselected without image > icon. Will nested list work better (than `<br>`)? test/jdk/javax/swing/JMenuItem/TestRadioAndCheckMenuItemWithIcon.java line 130: > 128: <br>1 JMenuItem with an image icon > 129: <br>1 JCheckBoxMenuItem menuitem with selected check mark > 130: <br>1 JRadioButtonMenuItem with a radio bullet A nested list would work better here. Description and tests for the "Menu(1)" could be in the first item and the checks would go in a nested list; then for "Menu2", you would place in the second list item and its nested list. <p>Overall introduction. <ol> <li><b>Menu(1)</b> <ul> <li>Description</li> <li>What to verify</li> </ul> </li> <li><b>Menu2</b> <ul> <li>Clicking on the "Menu2" will show <ul> <li>2 JMenuitems with only text</li> <li>1 JMenuItem with a red image icon</li> </ul> </li> <li>What to verify</li> </ul> </li> </ol> It would give a better structure to the description. test/jdk/javax/swing/JMenuItem/TestRadioAndCheckMenuItemWithIcon.java line 154: > 152: <ul> > 153: <li> > 154: <b>The red square imgae, check mark and radio bullet Suggestion: <b>The red square image, check mark and radio bullet Typo. ------------- Marked as reviewed by aivanov (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/29730#pullrequestreview-5767641589 PR Review Comment: https://git.openjdk.org/jdk/pull/29730#discussion_r4467012463 PR Review Comment: https://git.openjdk.org/jdk/pull/29730#discussion_r4686361807 PR Review Comment: https://git.openjdk.org/jdk/pull/29730#discussion_r4686375920 PR Review Comment: https://git.openjdk.org/jdk/pull/29730#discussion_r4686487564 PR Review Comment: https://git.openjdk.org/jdk/pull/29730#discussion_r4686397887 PR Review Comment: https://git.openjdk.org/jdk/pull/29730#discussion_r4686626945 PR Review Comment: https://git.openjdk.org/jdk/pull/29730#discussion_r4686501149
