JavaFX Multiple colors in textarea (JavaFX 8)

匿名 (未验证) 提交于 2019-12-03 01:14:02

问题:

I cannot find so much documentation in JavaFX.

And I will be happy to know how I can do this :

When I type a word in a textarea, fx "google" or "facebook". Can I so do like it can change color of google to fx green, and changes the font and stuff like that.

I will be happy to know how i can do this :).

回答1:

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

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

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.

The other options are:

  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 StackOverflow works).

Addressing additional coments

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

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!