In my TreeView, for some nodes, the first time they are opened they will display a number of ghost nodes. These are empty and appear below the real children of the node. They cannot be selected by mouse, but you can move the cursor towards them and give them focus. They donot react to anything else. They seem to be using an empty cell renderer (or the cell renderer with empty = true) as nothing appears in them (although the focus effect is visible). Examining a bugged node in the debugger reveals it only has its real children, and no empty children. For example, when there are 4 real children the size of the children list is 4 (in debugger), but double that amount of children is displayed.
The empty nodes always appear below the real nodes. Closing the node sometimes doesn't always work the first time -- sometimes the ghost nodes disappear then (but without closing the node). Once the node is closed, and then reopened the tree acts normally. In other words, this problem appears the first time a node is opened but never afterwards.
I'm unable to provide a working sample where this occurs so far, but I'm hoping this issue may already be known. This is the class fills the children; debugging this shows definitely no more than 4 children are being added:
private final class MediaNodeTreeItem extends TreeItem<MediaNode> {
private boolean childrenPopulated;
private MediaNodeTreeItem(MediaNode value) {
super(value);
}
@Override
public boolean isLeaf() {
return getValue().isLeaf();
}
@Override
public ObservableList<TreeItem<MediaNode>> getChildren() {
ObservableList<TreeItem<MediaNode>> treeChildren = super.getChildren();
if(!childrenPopulated) {
childrenPopulated = true;
if(getValue().hasChildren()) {
for(MediaNode child : getValue().getChildren()) {
treeChildren.add(new MediaNodeTreeItem(child));
}
}
}
return treeChildren;
}
}
The empty nodes always appear below the real nodes. Closing the node sometimes doesn't always work the first time -- sometimes the ghost nodes disappear then (but without closing the node). Once the node is closed, and then reopened the tree acts normally. In other words, this problem appears the first time a node is opened but never afterwards.
I'm unable to provide a working sample where this occurs so far, but I'm hoping this issue may already be known. This is the class fills the children; debugging this shows definitely no more than 4 children are being added:
private final class MediaNodeTreeItem extends TreeItem<MediaNode> {
private boolean childrenPopulated;
private MediaNodeTreeItem(MediaNode value) {
super(value);
}
@Override
public boolean isLeaf() {
return getValue().isLeaf();
}
@Override
public ObservableList<TreeItem<MediaNode>> getChildren() {
ObservableList<TreeItem<MediaNode>> treeChildren = super.getChildren();
if(!childrenPopulated) {
childrenPopulated = true;
if(getValue().hasChildren()) {
for(MediaNode child : getValue().getChildren()) {
treeChildren.add(new MediaNodeTreeItem(child));
}
}
}
return treeChildren;
}
}