Skip to content

JDK-8287261: [macos] JList Focus Ring color doesn't follow Accent color changes on macOS #8896

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

Closed
wants to merge 2 commits into from

Conversation

honkar-jdk
Copy link
Contributor

@honkar-jdk honkar-jdk commented May 25, 2022

With the proposed fix, JList's focus ring color follows accent color changes. Previously the focus ring for JList was not prominently visible and did not follow accent color changes.

While investing a similar issue related to JTable (#7768 (comment)), it was observed that List.focusCellHighlightBorder was using the cellFocusRing color as well. This PR extends the focus ring accent color changes to JLists.

Related issues: JDK-7124282 , JDK-8261243

Summary of changes

  • focusCellHighlightBorder in AquaLookAndFeel changed which is used for cell border for lists and tables
  • code related to on-the-fly focus ring color refactored into a separate method (changeFocusRingColor()) for re-usability
  • changeFocusRingColor() called when PropertyChangeEvent == FRAME_ACTIVE_PROPERTY and the frame gains focus, instead of calling in individual swapSelectionColors in AquaFocusHandler.java
  • Common test added - CellFocusRingTest, which tests for both cases - Tables & Lists.

Before and After screenshots of JList (Screenshots from SwingSet2 demo)

Screen Shot 2022-05-25 at 3 55 49 PM


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-8287261: [macos] JList Focus Ring color doesn't follow Accent color changes on macOS

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/8896/head:pull/8896
$ git checkout pull/8896

Update a local copy of the PR:
$ git checkout pull/8896
$ git pull https://git.openjdk.java.net/jdk pull/8896/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 8896

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/8896.diff

@bridgekeeper
Copy link

bridgekeeper bot commented May 25, 2022

👋 Welcome back honkar! 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 openjdk bot added the rfr Pull request is ready for review label May 25, 2022
@openjdk
Copy link

openjdk bot commented May 25, 2022

@honkar-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 the client client-libs-dev@openjdk.org label May 25, 2022
@mlbridge
Copy link

mlbridge bot commented May 25, 2022

Webrevs


if (errorLog.isEmpty()) {
System.out.println("Test passed !!");
}
Copy link
Contributor

@TejeshR13 TejeshR13 Jun 1, 2022

Choose a reason for hiding this comment

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

} else { Can be in same line. (Applies to other places also)

.get(prefix + ".selectionBackground");
}

if (UIManager.getDefaults().get("CellFocus.color") != null
Copy link
Contributor

Choose a reason for hiding this comment

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

        if (UIManager.getDefaults().get("CellFocus.color") != null
                && UIManager.getDefaults().get("CellFocus.color")
                instanceof Color)

can be changed into

        if (UIManager.getDefaults().get("CellFocus.color")
                instanceof Color)

Since if the object is null then instanceof returns false.

Copy link
Contributor Author

@honkar-jdk honkar-jdk Jun 1, 2022

Choose a reason for hiding this comment

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

@TejeshR13 Your suggestion was to remove redundant null check. Correct, this is a better way to shorten the condition. Will have the changes done in the next commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated PR with changes

@mrserb
Copy link
Member

mrserb commented Jun 2, 2022

Can you please double check how the native applications/components look when the colors are "similar".

@honkar-jdk
Copy link
Contributor Author

Can you please double check how the native applications/components look when the colors are "similar".

@mrserb There are different variations in the native applications -

On Reminders App the background color remains the same (light gray) irrespective of changes in accent color.
Screen Shot 2022-06-02 at 9 54 06 AM

On edit mode it changes to -
Screen Shot 2022-06-02 at 9 59 20 AM

Under notification settings - the background color changes with accent color but it doesn't have a focus ring.

Screen Shot 2022-06-02 at 10 03 13 AM

At present a focus ring is added to JLists, but since it is almost the same color as the background it is not visible. To keep it consistent with JTable changes, the ring color is made brighter and prominent. Please let me know your suggestion or thoughts on the changes.

@prsadhuk
Copy link
Contributor

prsadhuk commented Jun 6, 2022

In "Finder" lists, it is always gray
whereas in "Desktop and screensaver", "Extensions", "Network" lists, it follows accent color
I dont see anywhere prominent focus ring is drawn encircling the list cell in native app
so probably we can just have our JList focused cell follow the accent color in JDK as well without any prominent ring..

@honkar-jdk
Copy link
Contributor Author

In "Finder" lists, it is always gray whereas in "Desktop and screensaver", "Extensions", "Network" lists, it follows accent color I dont see anywhere prominent focus ring is drawn encircling the list cell in native app so probably we can just have our JList focused cell follow the accent color in JDK as well without any prominent ring..

Based on @prsadhuk and @mrserb suggestions and the JList LAF on native applications, the cell focus ring might not be required. At present, the JList background color changes with accent color and does not require any additional fix. Hence will be withdrawing this PR.

@honkar-jdk honkar-jdk closed this Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

4 participants