RFR: 7124282: [macosx] Can't see table cell highlighter when the highlight border is the same color as the cell. [v3]

Prasanta Sadhukhan psadhukhan at openjdk.java.net
Mon Mar 14 13:18:54 UTC 2022


On Thu, 10 Mar 2022 22:22:29 GMT, Harshitha Onkar <duke at openjdk.java.net> wrote:

>> Previously while tabbing through the JTable cell, the cell highlighter/focus ring was not visible against the selection background. 
>> 
>> Changes are made to Aqua LAF to derive a brighter focus ring color by changing hue, saturation and brightness of selection background color so that it is visible while tabbing through `JTable` cells. A new method is added for this purpose which takes in `selectionBackground` color, does the hue, saturation and brightness manipulation and returns a new focus ring color. There are edge cases where the HSB transformation does not yield the right focus ring color, for these cases a default color is returned that is different and can be seen against the `selectionBackground`.
>> 
>> **Edge Cases**
>> **Selection Background**     -----       **Returned Focus Ring Color**
>> - White/ Black                        ----->          Gray
>> 
>> - Shade of Gray 
>> towards white (r=g=b >= 128)  ----->      Black
>> 
>> - Shade of Gray 
>> towards Black (r=g=b < 128)    ------>     White
>> 
>> A test case is added to compare the RGB difference between the original focus ring color & selection background and the brighter focus ring color & selection background.
>> 
>> PS: The native L&F (Mac OS) and Swing L&F for JTable cell tabbing differs (on native tables the cell background turns white on focus with a cell focus ring). Since the background for Swing tables can be set by users and also overridden by subclassing `DefaultTableCellRenderer`, and to adhere to current implementation of Swing, the cell background changes are not incorporated. Only the Focus Ring/ Cell Highlighter is made more prominent against the selection background.
>
> Harshitha Onkar has updated the pull request incrementally with one additional commit since the last revision:
> 
>   formatting changes to test case

src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java line 892:

> 890:             "Table.focusCellBackground", textHighlightText,
> 891:             "Table.focusCellForeground", textHighlight,
> 892:             "Table.focusCellHighlightBorder", new BorderUIResource.LineBorderUIResource(deriveContrastFocusRing(selectionBackground), 2),

You have used border thickness as 2 without relying on scale factor. Did you check if it looks same in retina as well as non-retina display?

src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java line 1192:

> 1190: 
> 1191:         //create and return Color corresponding to new hsbValues
> 1192:         return Color.getHSBColor(hsbValues[0], hsbValues[1], hsbValues[2]);

It seems you are only manipulating hue and saturation, not the brightness which is set to 1.0f throughout..need to change the javadoc comment

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

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



More information about the client-libs-dev mailing list