设置TextArea的背景
Setting Background of TextArea
我想为用户提供 select TextArea 颜色的可能性:
private void updateTextArea(){
textArea.setStyle("-fx-text-fill: #" + textColor + "; -fx-background-color: #" + backgroundColor);
}
但是这不会改变整个背景的颜色。我在 Internet 上发现要更改文本区域的背景,我需要在外部 CSS 文件中执行类似的操作。
.text-area .content {
-fx-background-color: black ;
}
如何使用 setStyle() 执行此操作?
您可以通过从 TextArea
中提取内容节点并对其应用样式来完成此操作。但它只有在 TextArea
上台.
后才有效
用法:
Node node = textArea.lookup(".content");
node.setStyle("-fx-background-color: black;");
我想为用户提供 select TextArea 颜色的可能性:
private void updateTextArea(){
textArea.setStyle("-fx-text-fill: #" + textColor + "; -fx-background-color: #" + backgroundColor);
}
但是这不会改变整个背景的颜色。我在 Internet 上发现要更改文本区域的背景,我需要在外部 CSS 文件中执行类似的操作。
.text-area .content {
-fx-background-color: black ;
}
如何使用 setStyle() 执行此操作?
您可以通过从 TextArea
中提取内容节点并对其应用样式来完成此操作。但它只有在 TextArea
上台.
用法:
Node node = textArea.lookup(".content");
node.setStyle("-fx-background-color: black;");