Skip to content

8365389: Remove static color fields from SwingUtilities3 and WindowsMenuItemUI #26783

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 4 commits into
base: master
Choose a base branch
from

Conversation

prrace
Copy link
Contributor

@prrace prrace commented Aug 14, 2025

This refactors some Swing code to pass args instead of using statics
The bug report suggests some further refactoring which could be considered later, but the most
important thing to do is to eliminate using statics to pass args.
I've added one other suggestion from the bug report to have the windows case call SU3 directly rather than via newly added static methods, but for the basic case, I left the pre-existing private instance methods.


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-8365389: Remove static color fields from SwingUtilities3 and WindowsMenuItemUI (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26783

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 14, 2025

👋 Welcome back prr! A progress list of the required criteria for merging this PR into master 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 14, 2025

@prrace This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8365389: Remove static color fields from SwingUtilities3 and WindowsMenuItemUI

Reviewed-by: psadhukhan, aivanov, dnguyen

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 77 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title 8365389 8365389: Remove static color fields from SwingUtilities3 and WindowsMenuItemUI Aug 14, 2025
@openjdk
Copy link

openjdk bot commented Aug 14, 2025

@prrace 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 14, 2025
@mlbridge
Copy link

mlbridge bot commented Aug 14, 2025

Webrevs

acceleratorSelectionForeground);
SwingUtilities3.setAcceleratorForeground(acceleratorForeground);
SwingUtilities3.paintAccText(g, lh, lr);
SwingUtilities3.paintAccText(g, lh, lr,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left this private method here rather than calling the SU3 code directly because this method was here all along, before the previous fix. Same for a couple of others.

Copy link
Member

Choose a reason for hiding this comment

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

Previously, these private methods did the work that's now performed by the new methods in SwingUtilities3.

It's fine to postpone removing these private methods.

acceleratorSelectionForeground);
SwingUtilities3.setAcceleratorForeground(acceleratorForeground);
SwingUtilities3.paintAccText(g, lh, lr);
SwingUtilities3.paintAccText(g, lh, lr,
Copy link
Member

Choose a reason for hiding this comment

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

Previously, these private methods did the work that's now performed by the new methods in SwingUtilities3.

It's fine to postpone removing these private methods.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 14, 2025
@aivanov-jdk
Copy link
Member

There are still static fields to store colors in WindowsMenuItemUI, do you want to get rid of those too? My bug report implied removing them, yet currently the static fields with colors remain intact in WindowsMenuItemUI.

Copy link
Contributor

@DamonGuy DamonGuy left a comment

Choose a reason for hiding this comment

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

Removal looks correct when I compare it to the original implementation PR. Double-checked this by building and testing the changes on all OS's and I don't see any issues. LGTM

@prrace
Copy link
Contributor Author

prrace commented Aug 15, 2025

There are still static fields to store colors in WindowsMenuItemUI, do you want to get rid of those too? My bug report implied removing them, yet currently the static fields with colors remain intact in WindowsMenuItemUI.

Yes I do. I overlooked them.

@aivanov-jdk
Copy link
Member

There are still static fields to store colors in WindowsMenuItemUI, do you want to get rid of those too? My bug report implied removing them, yet currently the static fields with colors remain intact in WindowsMenuItemUI.

Yes I do. I overlooked them.

If you do, this will resolve JDK-8365625 that I submitted a few minutes ago.

@prrace
Copy link
Contributor Author

prrace commented Aug 15, 2025

There are still static fields to store colors in WindowsMenuItemUI, do you want to get rid of those too? My bug report implied removing them, yet currently the static fields with colors remain intact in WindowsMenuItemUI.

Yes I do. I overlooked them.

If you do, this will resolve JDK-8365625 that I submitted a few minutes ago.

oh. ok. I guess I will look at your test case and confirm that .. and looks like it is a fully done regression test.
Maybe you want to push that yourself ?

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Aug 18, 2025
@aivanov-jdk
Copy link
Member

aivanov-jdk commented Aug 18, 2025

There are still static fields to store colors in WindowsMenuItemUI, do you want to get rid of those too? My bug report implied removing them, yet currently the static fields with colors remain intact in WindowsMenuItemUI.

Yes I do. I overlooked them.

If you do, this will resolve JDK-8365625 that I submitted a few minutes ago.

oh. ok. I guess I will look at your test case and confirm that .. and looks like it is a fully done regression test.

Yes, it is. It was easier to make it a full regression test.

Maybe you want to push that yourself ?

Yeah, I guess so. I didn't look to update this myself initially. When I left my first comment above, I didn't come up with a test that proves there's a bug even though I had a hunch.

Now I looked at the code and resolved the bug myself. I also submitted my PR #26826 that's based on yours.

I edited the subject of the JBS issue that this PR resolves, now it doesn't reference WindowsMenuItemUI.

@openjdk openjdk bot removed the rfr Pull request is ready for review label Aug 18, 2025
@aivanov-jdk
Copy link
Member

aivanov-jdk commented Aug 18, 2025

@prrace Your latest commit 1b67651 doesn't address the problem fully, you should also remove WindowsMenuItemUI.installDefaults.

I posted a comment where I said that I went ahead and submitted my own PR #26826 to resolve JDK-8365625. My PR removes the static fields from WindowsMenuItemUI and adds the regression test attached to the JBS issue.

I propose you revert commit 1b67651 and integrate this PR in the state it was last week with the updated subject that doesn't mention WindowsMenuItemUI.

@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 19, 2025
@prsadhuk
Copy link
Contributor

@prrace Your latest commit 1b67651 doesn't address the problem fully, you should also remove WindowsMenuItemUI.installDefaults.

Shouldn't we keep it in WIndowMenuItemUI
as in BasicLookAndFeel the fields are initialized as

"MenuItem.disabledForeground", null,
            "MenuItem.acceleratorForeground", menuText,
            "MenuItem.acceleratorSelectionForeground", textHighlightText,

whereas in WIndowsLookAndFeel it is

"MenuItem.disabledForeground", InactiveTextColor,
            "MenuItem.acceleratorForeground", MenuTextColor,
            "MenuItem.acceleratorSelectionForeground", SelectionTextColor,

so I think it would be better to initialize the defaults in the L&F it is currently on

@prrace
Copy link
Contributor Author

prrace commented Aug 20, 2025

@prrace Your latest commit 1b67651 doesn't address the problem fully, you should also remove WindowsMenuItemUI.installDefaults.

You are right. What's there just duplicates the super-class. Although I don't know what "problem" it causes.

I posted a comment where I said that I went ahead and submitted my own PR #26826 to resolve JDK-8365625. My PR removes the static fields from WindowsMenuItemUI and adds the regression test attached to the JBS issue.

I thought that was supposed to be a follow-on ONCE this was done and I indicated last week I'd be removing these.

I propose you revert commit 1b67651 and integrate this PR in the state it was last week with the updated subject that doesn't mention WindowsMenuItemUI.

I think this should go as it is, and that follow-on can be updated.
You can address the duplicate installDefaults()

Also I just noticed this comment
"I edited the subject of the JBS issue that this PR resolves, now it doesn't reference WindowsMenuItemUI"

I'd prefer you not have done that. In fact I was puzzled at the PR/JBS mismatch and restored the subject.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client [email protected] ready Pull request is ready to be integrated rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

4 participants