如何在JavaFXTextArea中删除此灰色顶部边框

如何在JavaFXTextArea中删除此灰色顶部边框,javafx,Javafx,我想要一个完全没有边框和背景效果的文本区域。纯白色。我试着去掉边框和背景,但是有一个奇怪的灰色边框停留在文本区域的顶部 在“投诉”一词下面,有一个文本区。我把所有的东西都去掉了,但那条灰线仍然保留着 textArea.setStyle("-fx-background-color: #fff; -fx-border-color: #fff; -fx-border-width: 0; -fx-border-image-width: 0; -fx-background-image: null; -f

我想要一个完全没有边框和背景效果的文本区域。纯白色。我试着去掉边框和背景,但是有一个奇怪的灰色边框停留在文本区域的顶部

在“投诉”一词下面,有一个文本区。我把所有的东西都去掉了,但那条灰线仍然保留着

textArea.setStyle("-fx-background-color: #fff; -fx-border-color: #fff; -fx-border-width: 0; -fx-border-image-width: 0; -fx-background-image: null; -fx-region-background: null;-fx-border-insets: 0; -fx-background-size:0; -fx-border-image-insets:0;");

可在modena.css文件中找到应用于
TextArea
的实际样式。如果要覆盖任何css属性,需要查找所有可能出现的样式类和伪类,然后查找给定属性的所有可能的值系列(用逗号分隔)

对于“背景色”属性,以下是默认值:

.text-area {
    -fx-background-color: linear-gradient(to bottom, derive(-fx-text-box-border, -10%), -fx-text-box-border),
        derive(-fx-base,-1%);
}
.text-area .content {
    -fx-background-color:
        linear-gradient(from 0px 0px to 0px 4px, derive(-fx-control-inner-background, -8%), -fx-control-inner-background);
}
.text-area:focused .content {
    -fx-background-color: 
        -fx-control-inner-background,
        -fx-faint-focus-color,
        linear-gradient(from 0px 0px to 0px 5px, derive(-fx-control-inner-background, -9%), -fx-control-inner-background);
}
因此,如果希望有一个完全白色的区域,没有边框,则必须将这些值覆盖为:

.text-area{
    -fx-background-color: #fff, #fff;
}

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

.text-area:focused .content {
    -fx-background-color: #fff;
}

这可能有点晚了,但它可能会帮助其他人

我需要使用JavaFXTextArea来显示多行文本,并且我想要与您描述的相同的外观:没有边框,只有文本

以下是我使用的样式:

textArea.setStyle("-fx-focus-color: transparent; -fx-text-box-border: transparent;");

在JavaFX8中,如下所示:

.text-area {
    -fx-background-insets: 0;
    -fx-background-color: transparent, white, transparent, white;
}

.text-area .content {
    -fx-background-color: transparent, white, transparent, white;
}

.text-area:focused .content {
    -fx-background-color: transparent, white, transparent, white;
}

.text-area:focused {
    -fx-highlight-fill: #7ecfff;
}

.text-area .content {
    -fx-padding: 10px;
    -fx-text-fill: gray;
    -fx-highlight-fill: #7ecfff;
}
两点建议:一,。发布一个日志,以便有人可以为自己重新创建问题。2.用于帮助您确定边界的来源。