Is it possible in TextArea to make the color of a part of the text, for example, so that some repeated word is green?

    1 answer 1

    No, but you can use RichTextFX :

    import org.fxmisc.richtext.InlineCssTextArea; InlineCssTextArea area = new InlineCssTextArea(); // Поставить зелёный текст на четвёртой строчке area.setStyle(4, "-fx-fill: green;"); 

    Better yet, use TextFlow (available with javaFX 8):

     Text text1 = new Text("Большой наклонный красный текст"); text1.setFill(Color.RED); text1.setFont(Font.font("Helvetica", FontPosture.ITALIC, 40)); Text text2 = new Text("Малый жирный синий текст"); text2.setFill(Color.BLUE); text2.setFont(Font.font("Helvetica", FontWeight.BOLD, 10)); //Соединение этих двух кусков TextFlow textFlow = new TextFlow(text1, text2);