2017-03-05 70 views
0

我用Stackoverflow来包装表格单元格中的文本。但是当我专注于表格行时,文字颜色不再改变。我尝试了一切。JavaFX TableView封装文本选择行文本颜色

这是我现在在我的控制器:

 colWie.setCellFactory(column -> { 
     return new TableCell<DraaiboekActie, String>() { 
      private Text text; 

      @Override 
      public void updateItem(String item, boolean empty) { 
       super.updateItem(item, empty); 
       if (!isEmpty()) { 
        text = new Text(item); 
        text.wrappingWidthProperty().bind(colWie.widthProperty()); 
        text.getStyleClass().add("coltext"); 
        setGraphic(text); 
        } 
       } 
      }; 
     }); 

这是我在我的CSS:

.coltext { 
-fx-fill: white; 
} 

.coltext:focused:selected:filled{ 
-fx-fill: black; 
} 

回答

0

你需要像

.table-cell .coltext { 
    -fx-fill: white ; 
} 

.table-cell:focused:filled:selected .coltext { 
    -fx-fill: black ; 
} 

(我假设coltextdraaiboektext应该是相同的东西。)