每次我拖动一列时,我都会得到一条横跨整列的蓝线。 我知道我可以通过设置 此行仅在我拖动它时出现,如果我不这样做,一切都很好。-fx-background-insets: 0;
来删除它,但我不知道该把它放在哪里。
我当前的 CSS
如下:
.table-view .column-header,
.table-view .filler,
.table-view .column-header-background .show-hide-columns-button {
-fx-background-color: white;
}
.table-view .column-header {
-fx-border-color: grey;
-fx-border-width: 0 1 0 0;
}
.table-view .column-header-background {
-fx-border-color: grey;
-fx-border-width: 0 0 1 0;
}
.table-view .show-hide-column-image {
-fx-background-color: black;
}
.table-view .column-drag-header,
.table-view .column-overlay {
-fx-background-color: green;
}
.table-view:focused > .virtual-flow > .clipped-container > .sheet > .table-row-cell:filled:selected,
.table-view:focused > .virtual-flow > .clipped-container > .sheet > .table-row-cell .table-cell:selected {
-fx-background-color: darkgrey;
-fx-table-cell-border-color: grey;
}
.table-cell {
-fx-border-color: grey;
-fx-border-width: 0 1 0 0;
-fx-text-fill: black;
}
.table-row-cell:focused {
-fx-background-insets: 0;
}
.table-row-cell:selected .table-cell {
-fx-text-fill: black;
}
我在 modena.css
中看到的关于此“拖动事件”的唯一信息这是:
/* When a column is being 'dragged' to be placed in a different position, there
is a region that follows along the column header area to indicate where the
column will be dropped. This region can be styled using the .column-drag-header
name. */
.table-view .column-drag-header,
.tree-table-view .column-drag-header {
-fx-background: -fx-accent;
-fx-background-color: -fx-selection-bar;
-fx-border-color: transparent;
-fx-opacity: 0.6;
}
/* Semi-transparent overlay to indicate the column that is currently being moved */
.table-view .column-overlay,
.tree-table-view .column-overlay {
-fx-background-color: darkgray;
-fx-opacity: 0.3;
}
我试过像这样把它放在两个地方:
.table-view .column-drag-header,
.table-view .column-overlay {
-fx-background-insets:0;
}
但是没有效果。
我想也许这个“区域”是有插图的,正是因为它才出现蓝线,但我找不到它在哪里,或者至少找不到它在 CSS
中的名称。 .
编辑:将问题更改为“更改颜色”而不是将其删除,因为这似乎是更好的方法。 kleopatra 在评论中提供了更改颜色的解决方案。
.table-view .column-resize-line {
-fx-background-color: red;
}
最佳答案
在 Modena.css 中,CSS 类 .column-resize-line
可同时用于 TableView
和 TreeTableView
:
/* The column-resize-line is shown when the user is attempting to resize a column. */
.table-view .column-resize-line,
.tree-table-view .column-resize-line {
-fx-background: -fx-accent;
-fx-background-color: -fx-background;
-fx-padding: 0.0em 0.0416667em 0.0em 0.0416667em; /* 0 0.571429 0 0.571429 */
}
关于css - JavaFX - 在 TableView 中拖动 TableColumn 时更改蓝线的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59313486/