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:
<img alt="Color coded text" class="b-lazy" data-src="https://i.stack.imgur.com/Nc5QB.png" data-original="https://i.stack.imgur.com/Nc5QB.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />
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?Answer1:
<a href="https://github.com/TomasMikula/RichTextFX" rel="nofollow">RichTextFX</a> lets you to assign different styles to different ranges of text. You will have to parse the CSS yourself, though. See the <a href="https://github.com/TomasMikula/RichTextFX#automatic-highlighting-of-java-keywords" rel="nofollow">demo of highlighting Java keywords</a>