Skip to content

8365625: Can't change accelerator colors in Windows L&F #26826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aivanov-jdk
Copy link
Member

@aivanov-jdk aivanov-jdk commented Aug 18, 2025

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 that was resolved in #26743.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8365625: Can't change accelerator colors in Windows L&F (Bug - P3)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26826/head:pull/26826
$ git checkout pull/26826

Update a local copy of the PR:
$ git checkout pull/26826
$ git pull https://git.openjdk.org/jdk.git pull/26826/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26826

View PR using the GUI difftool:
$ git pr show -t 26826

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26826.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 18, 2025

👋 Welcome back aivanov! A progress list of the required criteria for merging this PR into pr/26783 will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Aug 18, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Aug 18, 2025

@aivanov-jdk The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added client [email protected] rfr Pull request is ready for review labels Aug 18, 2025
@mlbridge
Copy link

mlbridge bot commented Aug 18, 2025

Webrevs

@openjdk
Copy link

openjdk bot commented Aug 18, 2025

@aivanov-jdk this pull request can not be integrated into pr/26783 due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout 8365625-accelator-colors-WindowsLAF
git fetch https://git.openjdk.org/jdk.git pr/26783
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge pr/26783"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Aug 18, 2025
Color acceleratorForeground = UIManager.getColor("MenuItem.acceleratorForeground");
Color acceleratorSelectionForeground = UIManager.getColor("MenuItem.acceleratorSelectionForeground");
UIManager.put("MenuItem.acceleratorForeground", Color.GREEN);
UIManager.put("MenuItem.acceleratorSelectionForeground", Color.RED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are testing 2 of 3 static fields..I guess since we do not have test for these fields explicitly, we can test the 3rd one too which is disabledForeground

like putting UIManager.put("MenuItem.disabledForeground", Color.BLUE)
and do quit.setEnabled(false) in which case it should be BLUE

@openjdk-notifier openjdk-notifier bot changed the base branch from pr/26783 to master August 21, 2025 20:51
@openjdk-notifier
Copy link

The parent pull request that this pull request depends on has now been integrated and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork:

git checkout 8365625-accelator-colors-WindowsLAF
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client [email protected] merge-conflict Pull request has merge conflict with target branch rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants