Hello,
Andy!
Thank you
very much
for your
reply! The
solution
you
provided
helped.
However,
in this
case, my
CSS styles
are
hardcoded.
Could you
let me
know if
there are
any plans
to support
styling
text in
editable
RichTextArea
using CSS
classes?
Best
regards,
Pavel
On 4/3/26
18:32,
Andy
Goryachev
wrote:
Dear
Pavel:
Thank
you for
your
feedback!
Right
now, I
think
the only
one way
is
a custom
attribute.
Take a
look at
this
example,
where a
custom
CSS_CHAR
attribute
is used
with a
custom
RichTextArea
that
adds
support
for it:
https://github.com/andy-goryachev-oracle/Test/blob/main/src/goryachev/research/RichTextArea_CustomAttributes_Example.java
Keep in
mind
that
there
could be
only one
such
attribute
set on a
text
segment
(even
though
the
attribute
value
may
specify
multiple
-fx-
properties).
This
means
you need
to
implement
your own
logic to
merge
the
values
if you
want to
"apply"
a
property
to a
selection.
Hope
this
helps.
Let me
know how
if it
works in
your use
case.
Thanks,
-andy
*From:
*PavelTurk
<[email protected]>
*Date:
*Friday,
April 3,
2026 at
07:12
*To:
*[email protected]
<[email protected]>
*Subject:
*[External]
: What
is the
right
way to
set
styles
in
RichTextArea
when the
user can
change
the
theme?
Hi
everyone,
I have a
question
about
working
with
styles
when the
user can
change
the
theme
(for
example,
from
light to
dark, or
even
within
different
dark
variants).
Here’s
the
situation:
I’m
building
a simple
console
where
the user
enters
commands,
the
commands
are
executed,
and
output
is
displayed
with
styling.
With
RichTextFX,
it was
simple —
I just
added a
piece of
text and
assigned
a CSS
class.
When the
user
changed
the
theme,
all the
styles
updated
automatically.
Now I’m
trying
to do
something
similar
with JFX
RichTextArea,
but
unfortunately
I
haven’t
figured
out how
yet. The
only API
I found
for
working
with CSS
styles
is
RichParagraph.builder().
But as
far as I
understand,
it’s
supposed
to be
used
only
with
SyntaxDecorator.
That’s
fine in
theory,
but in
that
case I
would
have to
store
the
model of
my
command
output,
which
would
significantly
complicate
things.
On the
other
hand,
there is
SimpleViewOnlyStyledModel,
but as I
understand
it,
that’s
for
read-only
text,
which
doesn’t
suit my
needs.
Could
someone
suggest
which
API I
should
use for
my case?
Best
regards,
Pavel