简体   繁体   English

JavaFX:在TextFlow中设置背景色

[英]JavaFX: Set Background Color in TextFlow

I have a text flow widget in my JavaFx application for which I need to change the background color. 我的JavaFx应用程序中有一个文本流小部件,需要更改其背景颜色。

The layout is constructed using FXML, and the background color for the text flow needs to be set using external css file. 使用FXML构造布局,并且需要使用外部css文件设置文本流的背景色。

I'm able to set the background color for both textArea and textField, but unable to do so for textFlow. 我可以为textArea和textField设置背景颜色,但不能为textFlow设置背景颜色。

Simply set the -fx-background-color property the same way you'd do it for other Region s eg: 只需以与对其他Region相同的方式设置-fx-background-color属性即可,例如:

TextFlow {
    -fx-background-color: lightblue;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM