5

テーブルビューがあり、次の場合に行のデフォルトの色を変更したい...
1. ... 行の上にカーソルを置きます。
2. ... 行を選択しました。

cssファイルですべてを行う簡単な方法はありますか?

私が見つけたのは、ケース1の場合、設定できることだけです

.table-cell:hover { -fx-background-color: green; }

cssファイルで。これにより、セルの色は変わりますが、行全体の色は変わりません。

.table-view .row-selection:hover{ -fx-background-color: lightgreen; } 私が試した他の多くの組み合わせは機能しません。

4

1 に答える 1

18
/* Selected row */
.table-view:focused .table-row-cell:filled:focused:selected {
    -fx-background-color: brown;
    -fx-background-insets: 0, 1, 2;
    -fx-background: -fx-accent;
    -fx-text-fill: -fx-selection-bar-text;
}

/* Selected row when table not focused */
.table-row-cell:filled:focused:selected {
    -fx-background-color: red;
    -fx-background-insets: 0, 1, 2;
    -fx-background: -fx-accent;
    -fx-text-fill: -fx-selection-bar-text;
}

/* Row hovered */
.table-view:row-selection .table-row-cell:filled:hover {
    -fx-background-color: green;
    -fx-background-insets: 0, 0 0 1 0;
    -fx-text-fill: -fx-text-inner-color;
}

/* Selected row hovered */
.table-view:focused .table-row-cell:filled:focused:selected:hover {
    -fx-background: -fx-accent;
    -fx-background-color: yellow;
    -fx-background-insets: 0, 1, 2;
    -fx-text-fill: -fx-selection-bar-text;
}

/* Selected row hovered when table not focused */
.table-view:row-selection .table-row-cell:filled:focused:hover {
    -fx-background-color: blue;
    -fx-background-insets: 0, 0 0 1 0, 1 1 2 1, 2 2 3 2, 3 3 4 3;
    -fx-text-fill: -fx-text-inner-color;
}
于 2012-10-05T13:27:51.917 に答える