On Fri, 20 Jun 2025 03:09:32 GMT, Prasanta Sadhukhan <psadhuk...@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..

> One more thing I observed is "If we change the order of menu creation" then 
> the icons rendered are different. For e.g. if the order is
> 
> Shouldn't the icons for the L&Fs be same ?

That's the purpose of the test but it fails to test it.

You've just found another proof that multiple L&Fs can't be used concurrently. 
I've been talking about it since [the very start of this code 
review](https://github.com/openjdk/jdk/pull/25907#pullrequestreview-2953647827).

When you change L&F, all the `UIDefaults` of the old L&F are removed and values 
for the newly installed L&F are added.

If a component or its UI doesn't store a setting, such as color, font or icon, 
in its field, the setting is retrieved from `UIDefaults` — but the values are 
different now.

This is what happens in the current test without any changes. After Windows L&F 
is installed, the L&F is switched back to the whatever L&F was initially. As 
the result, there are no check marks and bullets in Windows L&F.

The test has to re-create its UI after testing for a L&F is complete. Such a 
scenario isn't supported by `PassFailJFrame` at the moment, see 
[JDK-8357455](https://bugs.openjdk.org/browse/JDK-8357455) and 
https://github.com/openjdk/jdk/pull/24439#discussion_r2100038079. There's no 
easy workaround.

The test doesn't receive events from `PassFailJFrame`, so the needs to be a 
custom UI, or the test should be run several times for different L&Fs.

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

PR Comment: https://git.openjdk.org/jdk/pull/25907#issuecomment-3035368348

Reply via email to