sazzy4o sazzy4o - 1 year ago 190
Java Question

Is it possible to set different colors for different lines in a javafx textField/Area?

I know that you can set a color of a whole textArea/Field by setting the style of the node to be

-fx-text-fill: red;
but is there a way to set the color of one single line instead of all of the lines while still keeping the textArea/Field editable?

Answer Source

JavaFX's TextField/TextArea does not support that. You can use RichTextFX for the job:

import org.fxmisc.richtext.InlineCssTextArea;

InlineCssTextArea area = new InlineCssTextArea();

// set style of line 4
area.setStyle(4, "-fx-fill: red;");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download