2015-04-05 69 views

回答

1

也许每一行都可以是一个系列,然后你可以使用css改变选择行。我用它来改变表格视图中所选数据的颜色。

table.getSelectionModel().selectedIndexProperty().addListener((observable, oldValue, newValue) -> colorPeak(oldValue, newValue)); 
 

 
    public void colorPeak(Number oldV, Number newV){ 
 
    \t if(oldV.intValue() != -1){ 
 
    \t \t lineChart.getData().get(oldV.intValue()).getNode().setId("serie-unselect"); 
 
    \t } 
 
    \t if(newV.intValue() != -1){ 
 
    \t \t lineChart.getData().get(newV.intValue()).getNode().setId("serie-select"); 
 
    \t } 
 
    }
#serie-unselect { 
 
\t -fx-stroke: blue; 
 
} 
 

 
#serie-select { 
 
    -fx-stroke: //color of the background 
 
}