Dear Timo:

Good question!

At this point, the embedded images can be used in a custom model, or a 
view-only model.  The basic idea is that the model creates a RichParagraph in 
its getParagraph(int index) method.  Note that the RichParagraph is just a way 
to communicate the model's data, the model may use some other mechanism for 
storing its data.

You use RichParagraph.Builder to build the paragraph.  Use 
addInlineNode(Supplier<Node> generator) to add a Node that contain the actual 
image.  You can use ImageCellPane  for that purpose, but in reality I suspect 
the actual Node that presents an image data may depend on the application 
requirements.

Alternatively, you can use SimpleViewOnlyStyledModel, see an example in the 
DemoModel:138.

Finally, support for embedded images is currently absent in the RichTextModel 
(the default model for RichTextArea).  I've created 
https://bugs.openjdk.org/browse/JDK-8357582 to rectify that.

Hope this helps, and thank you for the feedback - keep it coming!

-andy



From: Timo <REDACTED@REDACTED>
Date: Thursday, May 22, 2025 at 04:18
To: Andy Goryachev <andy.goryac...@oracle.com>
Subject: [External] : richtextarea / documentation / feedback
Hi Andy

Thanks for the richtextarea which is highly appreciated and needed.
Unfortunately, i dont know how to use it when coming to more
sophisticated examples - like a RichParagraph.

Reading the readme did not help as it ends with the builder.
How to append it to the editor?

Feedback, if i can go ahead solving this issue, i need to handle images. 
otherwise
it does not make sense at all.  If i manage to do so i can go ahead and gladly 
share
feedback. So far, it looks very good and reliable.

If you can provide a code snippet on that would be great.

Thank you for your effort!
Best regards, Timo

Reply via email to