RFR: 8346753: Test javax/swing/JMenuItem/RightLeftOrientation/RightLeftOrientation.java fails on Windows Server 2025 x64 because the icons of RBMenuItem and CBMenuItem are not visible in Nimbus LookAndFeel [v4]

Alexey Ivanov aivanov at openjdk.org
Mon Jul 7 12:40:41 UTC 2025


On Mon, 7 Jul 2025 05:18:56 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> Issue is RadioButtonMenuItem and CheckBoxMenuItem bullet/checkmark icon is not displayed in WindowsL&F when the test is run with NimbusL&F.
>> This is because `WindowsIconFactory#VistaMenuItemCheckIcon.paintIcon` called `getLaFIcon()` which returns a empty NimbusIcon which causes no icons to be drawn. This is because the test after setting WIndows L&F of the menuitem reverts back the Windows L&F to Nimbus L&F via `UIManager.setLookAndFeel(save);` call in the test so when frame is made visible, the L&F resets back to Nimbus L&F resulting in null NimbusIcon.
>> 
>> Fix is made to make sure the whole frame is updated to cater to L&F change via `SwingUtilities.updateComponentTreeUI(frame);` call and keep the L&F without reverting back to original L&F..
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   setsize

Looks good now, although I haven't run the test now.

There's a small nit around formatting to make the test code easier to read.

test/jdk/javax/swing/JMenuItem/RightLeftOrientation.java line 111:

> 109:             }
> 110:         });
> 111:         System.out.println("Test for LookAndFeel " + lafClassName);

Suggestion:

        if (args.length < 1) {
            throw new IllegalArgumentException("Look-and-Feel keyword is required");
        }

        final String lafClassName;
        switch (args[0]) {
            case "metal" -> lafClassName = UIManager.getCrossPlatformLookAndFeelClassName();
            case "motif" -> lafClassName = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
            case "windows" -> lafClassName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
            default -> throw new IllegalArgumentException(
                           "Unsupported Look-and-Feel keyword for this test: " + args[0]);
        }

        SwingUtilities.invokeAndWait(() -> {
            try {
                UIManager.setLookAndFeel(lafClassName);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });

        System.out.println("Test for LookAndFeel " + lafClassName);

Add some blank lines to split the long stretch of code into smaller logical blocks, which is easier to read.

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

Marked as reviewed by aivanov (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/25907#pullrequestreview-2993659269
PR Review Comment: https://git.openjdk.org/jdk/pull/25907#discussion_r2189954518


More information about the client-libs-dev mailing list