Multiple colors in JavaFX Textarea

谁说胖子不能爱 提交于 2019-12-12 04:56:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!