【发布时间】:2016-03-17 06:00:41
【问题描述】:
private TableColumn<FundedResearch, String> makeStringColumnRes(String columnName, String propertyName, int prefWidth) {
TableColumn<FundedResearch, String> column = new TableColumn<>(columnName);
column.setCellValueFactory(new PropertyValueFactory<FundedResearch, String>(propertyName));
column.setCellFactory(new Callback<TableColumn<FundedResearch, String>, TableCell<FundedResearch, String>>() {
@Override public TableCell<FundedResearch, String> call(TableColumn<FundedResearch, String> soCalledFriendStringTableColumn) {
return new TableCell<FundedResearch, String>() {
private Text text;
@Override public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (item != null) {
text=new Text(item.toString());
text.setWrappingWidth(column.getWidth());
text.setStyle("-fx-font-color:#FFFFFF");
column.setStyle("-fx-font-color:#FFFFFF");
this.setWrapText(true);
setGraphic(text);
setStyle("-fx-font-color:#FFFFFF");
}
}
};
}
});
if(prefWidth!=0){
column.setPrefWidth(prefWidth);
column.setMaxWidth(prefWidth);
column.setMinWidth(prefWidth);
}
return column;
}
我有这个方法被称为制作表格列。我已将字符串包装到单元格以使所有文本可见。问题是我不能让字体颜色变白。分享你的想法。谢谢你。 :) if statement 中设置的那些样式是我迄今为止尝试过的。谢谢
【问题讨论】: