RFR: 7093691: Nimbus LAF: disabled JComboBox using renderer has bad font color [v7]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Wed Mar 8 06:46:16 UTC 2023
On Thu, 2 Mar 2023 22:43:00 GMT, Damon Nguyen <dnguyen at openjdk.org> 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 debug line. Add StringBuffer for fail msg
It seems the test fails on windows for WIndows L&F..This is what I got
./jdk/bin/java DisabledComboBoxFontTestAuto
PASSED
PASSED
PASSED
Windows Enabled RGB failure: 240, 240, 240 vs 225, 225, 225
PASSED
Exception in thread "main" java.lang.RuntimeException: FAIL - Enabled and disabled ComboBox does not match in these LAFs: Windows
at DisabledComboBoxFontTestAuto.main(DisabledComboBoxFontTestAuto.java:178)
It seems it does not fail in mach5 maybe because it is not run in hidpi system.
Also, I was expecting some explanation about this snippet if it is still needed for GTK (because of which, I think, you had to do the change in `javax/swing/DefaultListCellRenderer.java`)
https://github.com/openjdk/jdk/blob/21a6ab1e3ea5228a31955d58fe75e5ae66d1c6cd/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java#L552-L560
You took care of `enabled `property..If the above snippet still hold significance, do we need to do the same for `orientation `property too
-------------
PR: https://git.openjdk.org/jdk/pull/12390
More information about the client-libs-dev
mailing list