是否可以在javafx textField / Area中为不同的行设置不同的颜色? [英] Is it possible to set different colors for different lines in a javafx textField/Area?

查看:802
本文介绍了是否可以在javafx textField / Area中为不同的行设置不同的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以通过将节点的样式设置为 -fx-text-fill:red; 来设置整个textArea / Field的颜色,但是有一种方法可以设置一行而不是所有行的颜色,同时仍保持textArea / Field可编辑?

I know that you can set a color of a whole textArea/Field by setting the style of the node to be -fx-text-fill: red; but is there a way to set the color of one single line instead of all of the lines while still keeping the textArea/Field editable?

推荐答案

JavaFX的 TextField / TextArea 不支持。您可以对作业使用 RichTextFX

JavaFX's TextField/TextArea does not support that. You can use RichTextFX for the job:

import org.fxmisc.richtext.InlineCssTextArea;

InlineCssTextArea area = new InlineCssTextArea();

// set style of line 4
area.setStyle(4, "-fx-fill: red;");

这篇关于是否可以在javafx textField / Area中为不同的行设置不同的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆