<Swing Dev> RFR: 8256019: JLabel HTML text does not support translucent text colors [v2]

Sergey Bylokhov serb at openjdk.java.net
Tue Nov 24 05:00:55 UTC 2020


On Fri, 20 Nov 2020 03:41:54 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> src/java.desktop/share/classes/javax/swing/plaf/basic/BasicHTML.java line 64:
>> 
>>> 62:     public static View createHTMLView(JComponent c, String html) {
>>> 63:         BasicEditorKit kit = getFactory();
>>> 64:         int beginIndex = html.indexOf("rgba(");
>> 
>> Don't we need to implement this parsing similarly to rgb()? somewhere inside kit.createDefaultDocument() or where we parse rgb()?
>
> The problem is the alpha color not being present in c.getForeground() so we need to parse alpha here to pass the value to displayPropertiesToCSS(). I have already mentioned it below.

As far as I understand the only place where we decode `rgb()` is `CSS.stringToColor` and that code missing the `rgba()` case.
Just to double-check.
If the test case `TestTranslucentLabelText` will be modified to use `rgb()` instead of `rgba()` then the color which was set by the user to the `Component` will be ignored, and the correct color from the `rgb()` will be used. So it does not matter that `c.getForeground()` contains some opaque color, it is ignored, why the similar case for` rgba()` does not work in the same way?

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

PR: https://git.openjdk.java.net/jdk/pull/1158


More information about the swing-dev mailing list