2017-03-05 27 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應該是相同的東西。)