<Swing Dev> [9] Review request for 8057791: Selection in JList is drawn with wrong colors in Nimbus L&F

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Mon Jun 20 12:13:27 UTC 2016


Hi, Anton.
I am a little bit worried about the change in 
NimbusStyle.getColorForState(). Before the fix we intentionally never 
return null from this method, but return DEFAULT_COLOR which has this 
javadoc:
     /**
      * <p>The Color to return from getColorForState if it would 
otherwise have
      * returned null.</p>
      *
      * <p>Returning null from getColorForState is a very bad thing, as 
it causes
      * the AWT peer for the component to install a SystemColor, which 
is not a
      * UIResource. As a result, if <code>null</code> is returned from
      * getColorForState, then thereafter the color is not updated for other
      * states or on LAF changes or updates. This DEFAULT_COLOR is used to
      * ensure that a ColorUIResource is always returned from
      * getColorForState.</p>
      */

And after the fix this method will return null for all ListCellRenderer.

Can you please clarify why the change states of "List.cellRenderer" in 
plaf/nimbus/skin.laf does not solve the problem?

> On 6/13/2016 12:12 AM, Anton Litvinov wrote:
>> Hello,
>>
>> Could you please review the following fix for the bug.
>>
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8057791
>> Webrev: http://cr.openjdk.java.net/~alitvinov/8057791/jdk9/webrev.00
>>
>> The bug is the fact that selected elements in "javax.swing.JList"
>> component are drawn with wrong background and foreground colors,
>> though "JList.getSelectionForeground()",
>> "JList.getSelectionBackground()" methods return the correct color
>> values for the tested JList instance.
>>
>> Wrong colors are returned in run time from the method
>> "javax.swing.plaf.synth.SynthStyle.getColor" for
>> "javax.swing.plaf.synth.SynthListUI.SynthListCellRenderer" instance,
>> because it can be only in 1 state "SynthConstants.ENABLED" and cannot
>> be in "SynthConstants.SELECTED" state, therefore the call from this
>> method to
>> "javax.swing.plaf.nimbus.NimbusStyle.getColorForState(SynthContext,
>> ColorType)" method always returns some wrong default L&F foreground,
>> background colors which are observed in this bug.
>>
>> All automatic regression tests from open and closed sets located in
>> "javax/swing/JList", "javax/swing/plaf/nimbus" directories were run on
>> MS Windows 7 OS during verification of the fix.
>>
>> Thank you,
>> Anton
>


-- 
Best regards, Sergey.



More information about the swing-dev mailing list