RFR: 8365625: Can't change accelerator colors in Windows L&F [v3]
Alexey Ivanov
aivanov at openjdk.org
Tue Sep 16 15:35:54 UTC 2025
On Tue, 16 Sep 2025 15:33:07 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> **Problem:**
>>
>> The colors for the accelerators are cached in static fields: `disabledForeground`, `acceleratorSelectionForeground` and `acceleratorForeground`. As soon as this field is set to a non-`UIResource` value, the value cannot change.
>>
>> **Fix:**
>>
>> Remove the static fields for accelerator from `WindowsMenuItemUI` and use the fields inherited from `BasicMenuItemUI`, pass these fields as parameters to static methods.
>>
>> Additionally, I formatted the calls to `WindowsMenuItemUI.paintMenuItem` in one consistent way.
>>
>> I removed the redundant javadoc from `paintMenuItem` and added the missing `@Override` annotation.
>>
>> I provided a regression test. The test also reproduces [JDK-8365375](https://bugs.openjdk.org/browse/JDK-8365375) that was resolved in #26743.
>
> Alexey Ivanov has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains nine commits:
>
> - Update instructions to include the set of disabled menu items
> - Add disabled menu items to verify for MenuItem.disabledForeground
> - Merge master
> - Merge master
> - Align parameter list in WindowsMenuUI.paintMenuItem.
> - Merge master
>
> Accepted the versions of
> * WindowsCheckBoxMenuItemUI.java
> * WindowsMenuItemUI.java
> * WindowsMenuUI.java
> * WindowsRadioButtonMenuItemUI.java
> that existed in my branch.
> - 8365625: Can't change accelerator colors in Windows L&F
> - 8365389
> - 8365389
src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java line 171:
> 169: int defaultTextIconGap, JMenuItem menuItem,
> 170: String prefix) {
> 171: assert c == menuItem : "menuItem passed as 'c' must be the same";
This assert ensures `c` is always the same object as `menuItem`, therefore the `menuItem` parameter can be removed. This is for a later clean-up.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26826#discussion_r2352904254
More information about the client-libs-dev
mailing list