RFR: 7175396: The text on label is not painted red for Nimbus LaF. [v3]

Prasanta Sadhukhan psadhukhan at openjdk.org
Fri Oct 7 08:40:43 UTC 2022


On Thu, 29 Sep 2022 12:15:43 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> 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
>
> Do other L&Fs respect the `Label.foreground` color if the label text contains HTML?
> 
> Why is it set in each paint then? It should be set once in `installDefaults` and it should be removed in `uninstallDefaults`. In addition to that, it is to be installed if and only if `label.setForeground` is `null` or `instanceof UIResource`, and uninstalled if it is `instanceof UIResource`. If the user explicitly set foreground color of the label, it must not be overridden by the L&Fs.

Fair point..Updated to set in installDefaults

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

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



More information about the client-libs-dev mailing list