import javax.swing.tree.*;
static > JTree jDynamicTree_concurrent(final A root, final F1 makeChildren, fO... optParams) {
ret swing(func -> JTree {
final Q queue = startQ();
DefaultMutableTreeNode rootNode = new(root);
rootNode.add(new DefaultMutableTreeNode(jDynamicTree_dummy()));
final JTree tree = new JTree(rootNode);
tree.setShowsRootHandles(true);
tree.collapseRow(0);
final bool keepChildrenOnCollapse = optParam(optParams, 'keepChildrenOnCollapse, false);
//final bool makeChildrenIsFast = optParam(optParams, 'makeChildrenIsFast, false);
final bool debug = boolPar debug(optParams, true);
tree.addTreeWillExpandListener(new TreeWillExpandListener {
public void treeWillCollapse(TreeExpansionEvent e) {}
public void treeWillExpand(TreeExpansionEvent e) {
if (debug) print("treeWillExpand");
final DefaultMutableTreeNode node = cast e.getPath().getLastPathComponent();
if (keepChildrenOnCollapse && !jDynamicTree_isInDummyState(node)) ret;
queue.add(r {
print("Calling: " + makeChildren);
B raw = callF(makeChildren, (A) node.getUserObject());
print("raw => " + className(raw));
fL l = asList(raw);
if (debug) print("Have children: " + l(l));
swing {
if (replaceTreeNodeChildren_withDummyChild(node, l, jDynamicTree_dummy()))
((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node);
}
});
}
});
ret tree;
});
}