2017-09-21 52 views

回答

1

這兩種選擇應爲ListView做吧:

.list-cell:filled:selected { 
    -fx-background: orange; 
} 

.list-view:focused > .virtual-flow > .clipped-container > .sheet > .list-cell:filled:selected { 
    -fx-background: -fx-selection-bar; 
} 

要在TableView秒(這兩種細胞和行選擇)相同的顏色,你可以添加更多的選擇:

.table-row-cell:filled:selected, 
.tree-table-row-cell:filled:selected, 
.table-row-cell:filled > .table-cell:selected, 
.tree-table-row-cell:filled > .tree-table-cell:selected, 
.list-cell:filled:selected { 
    -fx-background: orange; 
} 

.table-view:focused > .virtual-flow > .clipped-container > .sheet > .table-row-cell:filled:selected, 
.tree-table-view:focused > .virtual-flow > .clipped-container > .sheet > .tree-table-row-cell:filled:selected, 
.table-view:focused > .virtual-flow > .clipped-container > .sheet > .table-row-cell .table-cell:selected, 
.tree-table-view:focused > .virtual-flow > .clipped-container > .sheet > .tree-table-row-cell .tree-table-cell:selected , 
.list-view:focused > .virtual-flow > .clipped-container > .sheet > .list-cell:filled:selected { 
    -fx-background: -fx-selection-bar; 
} 

注意:這些選擇器甚至可以定位爲TreeTableViews

其結果是:

enter image description here

+0

-fx選擇杆具有重音相同的效果。但是那灰色仍然是一樣的。 –

+0

我用JavaFX8試用過它們,對我來說它們工作正常。 – DVarga

+0

它僅適用於ListView,因爲TableView忽略它。 –