Responding to your earlier message, and thanks again for trying 
RichTextArea/CodeArea out and giving the feedback!

#1
Created ticket for the cursor issue: https://bugs.openjdk.org/browse/JDK-8364777

#2
CodeArea has the font property, which is styleable.  Use the same CSS as 
TextArea:

-fx-font
<font>
inherit
shorthand property for font-size, font-family, font-weight and font-style
-fx-font-family
<font-family>
inherit

-fx-font-size
<font-size>
inherit

-fx-font-style
<font-style>
inherit

-fx-font-weight
<font-weight>
inherit


Enhancements:

#3
RichParagraph::getSegments() is an implementation detail.  Of course it is 
possible to create a custom model, please use RichParagraph.Builder to build 
your paragraphs.

#4
Set common editor settings directly or via looked-up colors.

RichTextArea or CodeArea use different mechanisms for styling.  For the 
RichTextArea, one can use stylesheet or direct styles when building paragraph 
segments, please refer to RichParagraph.Builder.addWith***() methods.

The CodeArea is different, as it is essentially a plain text control with a 
decorator (or a syntax highlighter).  Since CodeModel supports in-memory and 
virtualized models, it might be more difficult to plug in syntax highlighters 
that work with a single, in-memory string.  One way to use the usual syntax 
highlighters is to create a custom model with getText() method.  The other 
would be to use a highlighter which only updates the parts that have been 
changed.

Hope this helps.  Did I miss anything?

Thanks again,
-andy




From: openjfx-dev <openjfx-dev-r...@openjdk.org> on behalf of mkpaz 
<quizy...@gmail.com>
Date: Saturday, August 2, 2025 at 09:42
To: openjfx-dev@openjdk.org <openjfx-dev@openjdk.org>
Subject: RichTextArea feedback and suggestions
Hello,

I’ve been testing the new RichTextArea control and encountered a few issues. 
Some may not be bugs, though I couldn't find existing reports, so I’m sharing 
them here.

- The cursor doesn’t change from TEXT to DEFAULT when hovering over the 
scrollbar.

https://drive.google.com/file/d/1ob_2d-abI4F0bVoNWVS6d51rwYTt3-1n/view?usp=drive_link
- Setting font-family doesn’t work in CoreArea (but works in RichTextArea)

.rich-text-area .content,  // only this line works
.code-area .content,
.code-area .content .label,
.code-area .content TextFlow {
    -fx-font-family: "JetBrains Mono";
    -fx-font-size: 14px;
}

I also hope there is room left for small enhancements:

- RichParagraph.getSegments() is abstract and package-private and a part of 
public API.
  Judging from API it's suposed to be extensible, otherwise it's not possible 
to create a custom model.
  
https://github.com/openjdk/jfx/blob/master/modules/jfx.incubator.richtext/src/main/java/jfx/incubator/scene/control/richtext/model

https://github.com/openjdk/jfx/blob/master/modules/jfx.incubator.richtext/src/main/java/jfx/incubator/scene/control/richtext/model/SimpleViewOnlyStyledModel.java#L354

- RichTextArea lacks the ability to set common editor settings directly or via 
looked-up colors. I've created a project that brings TextMate support to RTA, 
so I'm obtaining editor's background, text color and highlight color from the 
theme settings.

https://github.com/mkpaz/tm4javafx/blob/master/tm4javafx/src/main/java/tm4javafx/richtext/StyleHelper.java#L75



Thanks for adding RichText support to JavaFX! Should I report all these issues 
in JBS?
Best regards.

Reply via email to