JavaFX CSS样式的TextArea不工作 [英] JavaFX CSS styling of TextArea does not work

查看:1618
本文介绍了JavaFX CSS样式的TextArea不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个简单的JavaFX应用程序,但我不能得到一些CSS样式工作。
问题是 TextArea -fx-background-color 属性。



这是相关的CSS:

  .text-area { 
-fx-font-family:Consolas;
-fx-highlight-fill:#00ff00;
-fx-highlight-text-fill:#000000;
-fx-text-fill:#00ff00;
-fx-background-color:#000000;
}

所有字段按预期运行,除了 -fx -background-colour ,这显然什么也不做。我仍然有默认的白色背景。如下图所示,下面的 TextField 具有相同的CSS,但会按预期应用背景颜色。



我的问题的图片



pre> .text-area .content {
-fx-background-color:black;
}

...



或者,也可以参阅这个答案: JavaFX 8中textarea的透明背景


I'm writing a simple JavaFX application, but I can't get some of the CSS styling to work. The problem is the -fx-background-color property for my TextArea.

This is the relevant CSS:

.text-area {
  -fx-font-family: Consolas;
  -fx-highlight-fill: #00ff00;
  -fx-highlight-text-fill: #000000;
  -fx-text-fill: #00ff00;
  -fx-background-color: #000000;
}

All the fields perform as expected, except -fx-background-color, which apparently does nothing. I still have the default white background. As you can see in the picture, the TextField below, which has identical CSS, but does apply the background color as expected.

Picture of my problem

Any clues?

解决方案

You need to set the content:

  .text-area .content{
      -fx-background-color: black;
  }

...

Or see this answer maybe: Transparent background of a textarea in JavaFX 8

这篇关于JavaFX CSS样式的TextArea不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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