首页 > 解决方案 > 单元格背景超过单元格高度

问题描述

我有一个包含几列和几行的 TableView。这是CSS的摘录:

.table-view {
    -fx-font-size: 8.0pt;
}

.table-row-cell {
    -fx-cell-size: 1.8em;
}

在细胞工厂是:

StringBuilder style = new StringBuilder();
if (item.getWeight() != null) {
    style.append("-fx-font-weight: ").append(item.getWeight()).append("; ");
}
if (item.getTextColor() != null) {
    style.append("-fx-text-fill: ").append(item.getTextColor().toString().replace("0x","#")).append("; ");
}
if (item.getBackgroundColor() != null) {
    style.append("-fx-background-color: ").append(item.getBackgroundColor().toString().replace("0x","#")).append("; ");
}
setStyle(style.toString());

现在,问题是当我设置背景颜色时,背景变得大于单元格高度。

看看不同的高度

我找不到问题出在哪里。

标签: javafxtableviewjavafx-8

解决方案


推荐阅读