且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JavaFX textarea中的多种颜色(JavaFX 8)

更新时间:2022-02-15 02:15:45

不。 JavaFX 8不支持TextArea中文本的多种颜色。

No. JavaFX 8 does not support multiple colors for text in TextArea.

您可以尝试Tomas Mikula的 RichTextFX 控制并查看它是否适合您。

You could try Tomas Mikula's RichTextFX control and see if that works for you.


RichTextFX为JavaFX提供API文本区域设置文本范围。它旨在作为富文本编辑器和代码编辑器的基础,具有语法高亮。

RichTextFX provides a text area for JavaFX with API to style ranges of text. It is intended as a base for rich-text editors and code editors with syntax highlighting.

其他选项包括:


  1. 使用 HTMLEditor

  2. 嵌入许多基于HTML的文本编辑器之一(例如 CKEditor )。

  3. 采用降价样式编辑器,用户只需编辑纯文本标记文本在标准TextArea中,样式文本显示在另一个窗格中(类似于***的工作方式)。

  1. To use a HTMLEditor OR
  2. Embed one of the many HTML based text editors (e.g. CKEditor).
  3. Adopt a markdown style editor, where the user just edits plain markup text in a standard TextArea and the styled text is shown in another pane (similar to how *** works).

寻址其他内容


我找到了一个地方,告诉我可以使用TextFlow。所以我会尝试这个

I found a place, there tell me that I can use TextFlow. So i will try this

TextFlow是一个只读控件,不像TextArea那样可编辑。仅使用核心JavaFX 8组件从头开始创建功能丰富的可定制文本编辑器是一项庞大而复杂的任务,我不建议大多数人承担这一任务。相反,使用或贡献现有的JavaFX编辑器解决方案(如RichTextFX或可能出现的其他类似项目)可能会产生更好的结果和更高效的结果。

TextFlow is a readonly control, not editable like a TextArea is. Creating an feature rich styleable text editor from scratch using only core JavaFX 8 components is a large and complicated task, which I would not advise most people to undertake. Instead, using or contributing to existing JavaFX editor solutions such as RichTextFX or other similar projects which may arise would likely yield better results and a more productive outcome.