JavaFX Multiple colors in textarea (JavaFX 8)


Question

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
6
4/21/2014 5:54:18 PM

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.

12
8/12/2014 11:21:10 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon