0

JavaFX がTreeViewあり、選択されたセルのフォントの色を黒に変更して、選択されていないセルのように見せたいと考えています。(私は試しsetSelectionModel(null)ましたが、これはエラーをスローします。)それが重要な場合、セルは背景画像に透明な背景を持っています。

CSS:

.tree-view, .tree-cell {
    -fx-font: 20px "Segoe Print";
    -fx-background-color: transparent;
}

.tree-cell {
    -fx-background-color: transparent;
    -fx-padding: 0 0 0 0;
    -fx-text-fill: #000000;
}

.tree-cell:focused {
    -fx-text-fill: #000000;
}

.tree-cell:selected {
    -fx-text-fill: #000000;
}

.tree-cell .tree-disclosure-node {
    -fx-background-color: transparent;
    -fx-padding: 10 10 0 40;
}

.button {
    -fx-padding: 0 10 0 10;
}

結果: (「test4」が選択されます)

結果: (

これは、選択したセルのフォントの色を黒に設定する必要があるようですが、そうではありません。CSS ファイルが読み込まれて使用されているため (たとえば、フォントは正しく、他のものも変更しました)、それは問題ではありません。

4

2 に答える 2

0

透明な背景が必要で、選択したセルが選択されていないセルと同じように見えるようにする場合は、次のことができます。

.tree-view {
    -fx-text-background-color: black ;
    -fx-background-color: transparent ;
    -fx-selection-bar: transparent ;
}
于 2016-06-11T13:17:04.793 に答える