Will not happen.  CSS compatibility with a third party library is not a 
requirement in this case.

-andy



From: openjfx-dev <openjfx-dev-r...@openjdk.org> on behalf of PavelTurk 
<pavelturk2...@gmail.com>
Date: Monday, May 5, 2025 at 13:59
To: openjfx-dev@openjdk.org <openjfx-dev@openjdk.org>
Subject: Re: CodeArea: -fx-background-color doesn't work.
To be as clear as possible, here's what I need:

.test {
     -fx-set-somehow-background-color: green;
}

var builder = RichParagraph.builder();
builder.addWithStyleNames(segment, "test");

because, in parallel for RTFX I simply use its stylesheet:

.test {
     -rtfx-background-color: green;
}


So, for both code areas, I use same style classes for styling paragraph 
segments.

Best regards, Pavel
On 5/5/25 23:20, Andy Goryachev wrote:
Right, the API are missing currently.  I just point out the fact that you must 
use highlights for the purpose of highlighting text range(s) within the 
paragraph, since these ranges might contain semi-transparent Nodes.  Once 
JDK-8355774 is fixed you'll be able to style highlights with CSS and all will 
be well.  Right?

-andy



From: openjfx-dev 
<openjfx-dev-r...@openjdk.org><mailto:openjfx-dev-r...@openjdk.org> on behalf 
of PavelTurk <pavelturk2...@gmail.com><mailto:pavelturk2...@gmail.com>
Date: Monday, May 5, 2025 at 13:10
To: openjfx-dev@openjdk.org<mailto:openjfx-dev@openjdk.org> 
<openjfx-dev@openjdk.org><mailto:openjfx-dev@openjdk.org>
Subject: Re: CodeArea: -fx-background-color doesn't work.
Andy, thank you very much for your help.

That doesn’t work for me. As I mentioned before, I’m working with two CodeArea 
implementations - JFX and RTFX,
and CSS is the common styling mechanism. I can’t use code for one and CSS for 
the other.

Well, technically I could, but it just wouldn’t make any sense.

Best regards, Pavel
On 5/5/25 22:54, Andy Goryachev wrote:
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.

JDK-8355774 is pretty high on my list of things to do.

-andy

From: openjfx-dev 
<openjfx-dev-r...@openjdk.org><mailto:openjfx-dev-r...@openjdk.org> on behalf 
of PavelTurk <pavelturk2...@gmail.com><mailto:pavelturk2...@gmail.com>
Date: Monday, May 5, 2025 at 12:47
To: openjfx-dev@openjdk.org<mailto:openjfx-dev@openjdk.org> 
<openjfx-dev@openjdk.org><mailto:openjfx-dev@openjdk.org>
Subject: Re: CodeArea: -fx-background-color doesn't work.
Hello, Andy

Yes, I need to add a background color for a text segment within a paragraph 
using CSS.

I have just opened an issue with ID : 9078469.

Can anyone give an estimate of when this issue might be addressed? Background 
color is such a fundamental feature
that it's impossible to work without it.

Best regards, Pavel
On 5/5/25 22:09, Andy Goryachev wrote:
Dear Pavel:

Can you clarify what you are trying to do exactly?

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().

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.

-andy




From: openjfx-dev 
<openjfx-dev-r...@openjdk.org><mailto:openjfx-dev-r...@openjdk.org> on behalf 
of PavelTurk <pavelturk2...@gmail.com><mailto:pavelturk2...@gmail.com>
Date: Saturday, May 3, 2025 at 10:07
To: openjfx-dev@openjdk.org<mailto:openjfx-dev@openjdk.org> 
<openjfx-dev@openjdk.org><mailto:openjfx-dev@openjdk.org>
Subject: CodeArea: -fx-background-color doesn't work.
For styling CodeArea, I use exclusively style classes, and this is the 
foundation of my entire architecture.
Today I tried to implement search highlighting (via background color), but it 
didn't work. Below is my test code.

Can anyone tell me how to set the background color using CSS? For example, in 
RichTextFX's CodeArea,
they have -rtfx-background-color.

public class JfxCodeArea extends Application {

     @Override
     public void start(Stage primaryStage) throws Exception {
         String text = """
                       Lorem ipsum dolor sit amet, consectetur adipiscing elit, 
sed do eiusmod tempor incididunt
                       ut labore et dolore magna aliqua. Ut enim ad minim 
veniam, quis nostrud exercitation ullamco
                       laboris nisi ut aliquip ex ea commodo consequat. Duis 
aute irure dolor in reprehenderit
                       in voluptate velit esse cillum dolore eu fugiat nulla 
pariatur.
                       """;

         String css = """
             .test {
                 -fx-font-weight: bold;
                 -fx-fill: red;
                 -fx-background-color: green;
             }

         """;
         String data = "data:text/css;base64," + 
Base64.getEncoder().encodeToString(css.getBytes(StandardCharsets.UTF_8));

         CodeArea codeArea = new CodeArea();
         codeArea.getStylesheets().add(data);

         codeArea.setSyntaxDecorator(new SyntaxDecorator() {
             @Override
             public RichParagraph createRichParagraph(CodeTextModel model, int 
index) {
                 var builder = RichParagraph.builder();
                 builder.addWithStyleNames(model.getPlainText(index), "test");
                 return builder.build();
             }

             @Override
             public void handleChange(CodeTextModel m, TextPos start, TextPos 
end, int charsTop, int linesAdded, int charsBottom) {

             }
         });

         VBox.setVgrow(codeArea, Priority.ALWAYS);
         var button = new Button("Go!");
         button.setOnAction(e -> codeArea.setText(text));
         VBox root = new VBox(codeArea, button);
         Scene scene = new Scene(root, 600, 200);
         primaryStage.setScene(scene);
         primaryStage.show();

     }

     public static void main(String[] args) {
         launch(args);
     }
}

Best regards, Pavel



Reply via email to