JavaFX Textarea中的多种颜色 [英] Multiple colors in JavaFX Textarea
问题描述
如何在JavaFX中更改textarea中不同文本的颜色?我一直在做一些研究,我只能找到Java Swing的解决方案,而不是JavaFX。
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.
为了描述我的情况,我试图突出显示不同的关键字代码,就像IDE一样。基本上,像这样:
To describe my situation, I'm trying to highlight different keywords in code, like a IDE. Basically, like this:
在上图中,某些单词的颜色不同。( .list
为红色, span
是蓝色等等。)
In the above image, certain words are different colors.(.list
is red, span
is blue, etc.)
有谁知道如何将此效果应用于JavaFX Textarea?
Does anyone know how to apply this effect to a JavaFX Textarea?
推荐答案
RichTextFX 允许您为不同的文本范围指定不同的样式。但是,您必须自己解析CSS。请参阅突出显示Java关键字的演示
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
这篇关于JavaFX Textarea中的多种颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!