问题
How would I change the color of different text in a textarea in JavaFX? I've been doing some research, and I can only find solutions for Java Swing, not JavaFX.
To describe my situation, I'm trying to highlight different keywords in code, like a IDE. Basically, like this:
In the above image, certain words are different colors.(.list is red, span is blue, etc.)
Does anyone know how to apply this effect to a JavaFX Textarea?
回答1:
RichTextFX lets you to assign different styles to different ranges of text. You will have to parse the CSS yourself, though. See the demo of highlighting Java keywords
来源:https://stackoverflow.com/questions/25388378/multiple-colors-in-javafx-textarea