On Thu, 2 Feb 2023 16:33:06 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.

Here are screenshots of the bug and the UI elements after the fix is applied.

Disabled JComboBox with DLCR before fix:
<img width="644" alt="Screen Shot 2023-02-01 at 3 52 46 PM" 
src="https://user-images.githubusercontent.com/96267980/216385047-a9bde4f9-c33d-430b-b68f-f4a9df8bf8a9.png";>

After fix:
<img width="643" alt="Screen Shot 2023-02-01 at 3 46 19 PM" 
src="https://user-images.githubusercontent.com/96267980/216384982-1407f271-d28d-423f-843b-5e1c59ba984c.png";>

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

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

Reply via email to