RichTextArea: does CodeArea support code folding?

Andy Goryachev andy.goryachev at oracle.com
Tue Apr 29 19:24:38 UTC 2025


Code folding is not currently supported by the CodeArea, at least with the models provided.

It might be possible to implement the folding in a custom component, using the following steps:

- implement a custom line number component which shows the folding decorations, knows how to get the actual line numbers, and how to handle the fold/unfold events
- implement a model that knows how to fold, and exposes the folding APIs
- modify the behavior of the CodeArea to deal with the folding as required: copy/paste, navigation, etc.

I suppose it's possible to fold these features into the stock CodeArea, given sufficient interest from the community.

-andy



From: openjfx-dev <openjfx-dev-retn at openjdk.org> on behalf of PavelTurk <pavelturk2000 at gmail.com>
Date: Tuesday, April 29, 2025 at 12:12
To: openjfx-dev at openjdk.org <openjfx-dev at openjdk.org>
Subject: RichTextArea: does CodeArea support code folding?
RTFX CodeArea has methods for code folding:

codeArea.foldParagraphs(int, int)
codeArea.unfoldParagraphs(int);

However, I can't find something with 'fold' in https://download.java.net/java/early_access/javafx25/docs/api/jfx.incubator.richtext/jfx/incubator/scene/control/richtext/CodeArea.html

Could anyone say what methods are used for folding (if JFX CodeArea supports it).

Best regards, Pavel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20250429/95387300/attachment-0001.htm>


More information about the openjfx-dev mailing list