0
子を持ち、フォルダアイコンがグラフィックであり、他のノードがプレイリストアイコンを持つようにTreeView<Playlist>
をモデル化しました。スタイルがほぼの場合はですが、ノードを展開/折りたたむときにグラフィックアイコンが壊れます。TreeViewが奇妙な動作を拡大/縮小する
ノードをクリックすると、それは常に正しいスタイルを示しているが、拡大したときに/崩壊、または新しいノードが追加されたとき、このようなTreeView
行為:ここ
はの一部でありますTreeView
public class PlaylistTreeView extends TreeView<Playlist> {
public PlaylistTreeView() {
...
setShowRoot(false);
setCellFactory(treeView -> new PlaylistTreeCell());
...
}
private class PlaylistTreeCell extends TreeCell<Playlist> {
@Override
public void updateItem(Playlist p, boolean empty) {
super.updateItem(p, empty);
if(p == null || empty) {
textProperty().unbind();
setText("");
setGraphic(null);
}
else {
if(p.isFolder())
setId("playlist-folder-tree-cell");
else
setId("playlist-tree-cell");
textProperty().bind(p.nameProperty());
}
}
}
}
でTreeCell
定義されており、これらはcss
でそれらのコンポーネントに影響を与える唯一のスタイルですされているコード:
.tree-cell, .list-cell {
-fx-background-color: rgb(243, 243, 243);
}
#playlist-tree-cell {
-fx-graphic: url('../icons/playlist-black-icon.png');
}
#playlist-tree-cell:selected {
-fx-graphic: url('../icons/playlist-white-icon.png');
}
#playlist-folder-tree-cell {
-fx-graphic: url('../icons/playlist-folder-black-icon.png');
}
#playlist-folder-tree-cell:selected {
-fx-graphic: url('../icons/playlist-folder-white-icon.png');
}
.list-cell:selected, .tree-cell:selected {
-fx-background-color: black;
-fx-text-fill: white;
}
私はここで何が欠けていますか?