RFR: 7175396: The text on label is not painted red for Nimbus LaF. [v3]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Wed Sep 28 06:44:25 UTC 2022
On Tue, 27 Sep 2022 17:33:46 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Get color once during init
>
> src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java line 222:
>
>> 220: if (fgColor != null) {
>> 221: label.setForeground(fgColor);
>> 222: }
>
> Why is the color set to the `label` component during paint?
>
> Shouldn't it be `g.setColor(fgColor)`? And the above code which uses the `context` should be skipped if `fgColor != null`.
There are 2 ways JLabel can be used, one via html label and another normal label. Normal label text will work if we do `g.setColor(fgColor)` but html label will use [StyleSheet.paint](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java#L1939) which does not take into account foreground Color (guess unless it's provided by html tags which is not the case here) so I need to explicitly set the foreground color of label
-------------
PR: https://git.openjdk.org/jdk/pull/9900
More information about the client-libs-dev
mailing list