<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:"Yu Gothic";
panose-1:2 11 4 0 0 0 0 0 0 0;}
@font-face
{font-family:Aptos;
panose-1:2 11 0 4 2 2 2 2 2 4;}
@font-face
{font-family:"Iosevka Fixed SS16";
panose-1:2 0 5 9 3 0 0 0 0 4;}
@font-face
{font-family:"Times New Roman \(Body CS\)";
panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
{font-family:"\@Yu Gothic";
panose-1:2 11 4 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:10.0pt;
font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Iosevka Fixed SS16";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">You have to use highlights for that, since you can't assign CSS style to a part of the Text instance, and you can't set a background on it.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">JDK-8355774 is pretty high on my list of things to do.</span><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">-andy
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">openjfx-dev <openjfx-dev-retn@openjdk.org> on behalf of PavelTurk <pavelturk2000@gmail.com><br>
<b>Date: </b>Monday, May 5, 2025 at 12:47<br>
<b>To: </b>openjfx-dev@openjdk.org <openjfx-dev@openjdk.org><br>
<b>Subject: </b>Re: CodeArea: -fx-background-color doesn't work.<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:12.0pt">Hello, Andy<br>
<br>
Yes, I need to add a background color for a text segment within a paragraph using CSS.
<br>
<br>
I have just opened an issue with ID : 9078469.<br>
<br>
Can anyone give an estimate of when this issue might be addressed? Background color is such a fundamental feature
<br>
that it's impossible to work without it.<br>
<br>
Best regards, Pavel<br>
<br>
<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">On 5/5/25 22:09, Andy Goryachev wrote:<o:p></o:p></span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">Dear Pavel:</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">Can you clarify what you are trying to do exactly?</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">If you are trying to add a background to a text segment within the paragraph (as your code seem to indicate), then the only way to do it is to call Builder.addHighlight().</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">If you are trying to set the background of the whole paragraph, you've hit another missing API similar to JDK-8355774 - there is currently no way to style the paragraphs via
CSS. There is the Builder.setParagraphAttributes(StyleAttributeMap) but a CSS one is missing.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">-andy</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">openjfx-dev <a href="mailto:openjfx-dev-retn@openjdk.org">
<openjfx-dev-retn@openjdk.org></a> on behalf of PavelTurk <a href="mailto:pavelturk2000@gmail.com">
<pavelturk2000@gmail.com></a><br>
<b>Date: </b>Saturday, May 3, 2025 at 10:07<br>
<b>To: </b><a href="mailto:openjfx-dev@openjdk.org">openjfx-dev@openjdk.org</a> <a href="mailto:openjfx-dev@openjdk.org">
<openjfx-dev@openjdk.org></a><br>
<b>Subject: </b>CodeArea: -fx-background-color doesn't work.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">For styling CodeArea, I use exclusively style classes, and this is the foundation of my entire architecture.<br>
Today I tried to implement search highlighting (via background color), but it didn't work. Below is my test code.<br>
<br>
Can anyone tell me how to set the background color using CSS? For example, in RichTextFX's CodeArea,<br>
they have -rtfx-background-color.<br>
<br>
public class JfxCodeArea extends Application {<br>
<br>
@Override<br>
public void start(Stage primaryStage) throws Exception {<br>
String text = """<br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt<br>
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco<br>
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit<br>
in voluptate velit esse cillum dolore eu fugiat nulla pariatur.<br>
""";<br>
<br>
String css = """<br>
.test {<br>
-fx-font-weight: bold;<br>
-fx-fill: red;<br>
-fx-background-color: green;<br>
}<br>
<br>
""";<br>
String data = <span class="MsoHyperlink">"data:text/css;base64,"</span> + Base64.getEncoder().encodeToString(css.getBytes(StandardCharsets.UTF_8));<br>
<br>
CodeArea codeArea = new CodeArea();<br>
codeArea.getStylesheets().add(data);<br>
<br>
codeArea.setSyntaxDecorator(new SyntaxDecorator() {<br>
@Override<br>
public RichParagraph createRichParagraph(CodeTextModel model, int index) {<br>
var builder = RichParagraph.builder();<br>
builder.addWithStyleNames(model.getPlainText(index), "test");<br>
return builder.build();<br>
}<br>
<br>
@Override<br>
public void handleChange(CodeTextModel m, TextPos start, TextPos end, int charsTop, int linesAdded, int charsBottom) {<br>
<br>
}<br>
});<br>
<br>
VBox.setVgrow(codeArea, Priority.ALWAYS);<br>
var button = new Button("Go!");<br>
button.setOnAction(e -> codeArea.setText(text));<br>
VBox root = new VBox(codeArea, button);<br>
Scene scene = new Scene(root, 600, 200);<br>
primaryStage.setScene(scene);<br>
primaryStage.show();<br>
<br>
}<br>
<br>
public static void main(String[] args) {<br>
launch(args);<br>
}<br>
}<br>
<br>
Best regards, Pavel</span><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
</div>
</div>
</div>
</div>
</body>
</html>