void () { final DefaultTreeModel treeModel = (DefaultTreeModel)myTree.getModel(); final Object root = treeModel.getRoot(); if (!(root instanceof CheckedTreeNode rootNode)) return; final Couple<CheckedTreeNode> rootAndPreselectedNode = createRoot(); final CheckedTreeNode rootCopy = rootAndPreselectedNode.first; List<TreeNode> nodes = TreeUtil.listChildren(rootCopy); rootNode.removeAllChildren(); TreeUtil.addChildrenTo(rootNode, nodes); treeModel.reload(); }