java 如何更改表格视图上的边框线颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39171624/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I change the border lines COLOUR on the table view
提问by Milan
I have already tried the following code from Remove grid line in tableView, but that only allows me to change the vertical line colour and not the horizontal line colour.
我已经在 tableView 中的 Remove grid line 中尝试了以下代码,但这仅允许我更改垂直线颜色而不是水平线颜色。
So, I am trying to change the white border line colour which you can see in the image below, how would I change this colour? I am using JavaFX with CSS.
所以,我正在尝试更改您在下图中看到的白色边框线颜色,我将如何更改此颜色?我正在使用带有 CSS 的 JavaFX。
Here is my CSS:
这是我的 CSS:
.table-view{
-fx-background-color: transparent;
}
.table-view:focused{
-fx-background-color: transparent;
}
.table-view .column-header-background{
-fx-background-color: #262626;
}
.table-view .column-header-background .label{
-fx-background-color: transparent;
-fx-text-fill: #0ed9e0;
}
.table-view .column-header {
-fx-background-color: transparent;
}
.table-view .table-cell{
-fx-text-fill: #0ed9e0;
-fx-alignment: center;
}
.table-row-cell{
-fx-background-color: -fx-table-cell-border-color, #2b2a2a;
-fx-background-insets: 0, 0 0 1 0;
-fx-padding: 0.0em; /* 0 */
}
.table-row-cell:odd{
-fx-background-color: -fx-table-cell-border-color, #262626;
-fx-background-insets: 0, 0 0 1 0;
-fx-padding: 0.0em; /* 0 */
}
.table-row-cell:selected {
-fx-background-color: #005797;
-fx-background-insets: 0;
-fx-background-radius: 1;
}
回答by Peter
in order to change both vertical and horizontal color of borders you can use the following code in your css:
为了更改边框的垂直和水平颜色,您可以在 css 中使用以下代码:
.table-row-cell{
-fx-border-color: red;
-fx-table-cell-border-color:red;}
Also, you can change the border of the whole table (not the inner borders) with the following code:
此外,您可以使用以下代码更改整个表格的边框(而不是内部边框):
.table-view{
-fx-border-color: red;}