如何从文本区域边框中删除阴影

时间:2013-06-14 20:28:09

标签: javafx-2 javafx javafx-8

我想创建带黑色边框的文字区域。

TextArea dataPane = new TextArea();
dataPane.setStyle("-fx-border-color: black; -fx-border-width: 1; -fx-border-radius: 16;");

但我得到了这个结果:

enter image description here

你能告诉我如何删除这个蓝影吗?

2 个答案:

答案 0 :(得分:5)

蓝色边框不是阴影,而是JavaFX for caspian风格的默认焦点颜色。您可以在 caspian.css 中将其定义视为-fx-focus-color,其默认值为#0093ff

现在我们可以为每个控件覆盖此调色板。所以你做了

dataPane.setStyle("-fx-border-color: black; -fx-border-width: 1; "
                + "-fx-border-radius: 16; -fx-focus-color: transparent");

答案 1 :(得分:5)

如果要完全删除所有边框,阴影,高光:

.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;
}