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

Tejesh R duke at openjdk.java.net
Wed Jun 1 10:11:39 UTC 2022


On Wed, 25 May 2022 23:40:59 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:

> 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 (https://github.com/openjdk/jdk/pull/7768#discussion_r839813517), 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](https://bugs.openjdk.java.net/browse/JDK-7124282) , [JDK-8261243](https://bugs.openjdk.java.net/browse/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](https://user-images.githubusercontent.com/95945681/170382727-54ed155b-6f08-4c75-8657-89c15764e1cd.png)

test/jdk/javax/swing/JTable/CellFocusRingTest.java line 85:

> 83:         }
> 84: 
> 85:         if (UIManager.getDefaults().get("CellFocus.color") != null

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.

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

PR: https://git.openjdk.java.net/jdk/pull/8896



More information about the client-libs-dev mailing list