On Mon, 6 Feb 2023 19:04:07 GMT, Damon Nguyen <[email protected]> wrote:

>> Before the fix, a JComboBox in Nimbus L&F would have normal black text even 
>> when the JComboBox was disabled if SynthComboBoxRenderer was replaced with a 
>> DefaultListCellRenderer. This text should be greyed out like in other L&F's. 
>> When looking into the defaults for Nimbus L&F files for attributes and 
>> states of a JComboBox, it confirm that the intention for disabled 
>> JComboBoxes is nimbusDisabledText (which is grey text).
>> 
>> SynthComboBoxes have an additional check in its default 
>> SynthComboBoxRenderer that enables/disables the renderer itself. The 
>> SynthComboBoxRenderer inherits its enabled state from the parent ComboBox. 
>> Since the renderer with DefaultListCellRenderer is in a separate class 
>> without a reference to the comboBox, a listener was added to SynthComboBoxUI.
>> 
>> An additional issue occurred in DefaultListCellRenderer because the renderer 
>> overrode the listener's re-assigned enabled state. In testing, setting the 
>> enabled state in DefaultListCellRenderer is redundant for all L&F's and is 
>> not needed here. However, instead of removing it altogether, a conditional 
>> was added specifically to allow ComboBoxes to skip setting enabled state 
>> here.
>> 
>> After the fix, the Nimbus JComboBox with DLCR set matches the appearance of 
>> a normal Nimbus JComboBox. I can enable/disable the JComboBoxes in the test, 
>> and the UI elements behave and appear as expected.
>
> Damon Nguyen has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Remove unused var. Fix try catch

@prsadhuk could you review this as well since I got your input about this issue 
previously? 

Initially, I thought it was the default value of the disabled combobox, but 
none of the skin.laf UI states/values affected the displayed text color.

So, it may be a state issue as you suggested. I checked the enabled state of 
each L&F, and the combobox's state is correct, but I noticed that the renderer 
in Synth has an additional condition that sets the renderer to disabled/enabled 
to match the combobox state. In testing, setting the renderer to disabled 
produced the correct behavior, so I made a listener as a workaround to access 
the combobox's renderer for the case with a DefaultListCellRenderer.

With the test I created, this approach creates the correct behavior, so I 
implemented the fix the cleanest way possible.

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

PR: https://git.openjdk.org/jdk/pull/12390

Reply via email to