void () { TreeNode rootNode = myModel.getRoot(); if (rootNode == null) return; MyProjectStructure treeStructure = myModel.getTreeStructure(); Object element = treeStructure.getRootElement(); myModel.expand(element, myTree, path -> { }); for (Object childElement : treeStructure.getChildElements(element)) { myModel.expand(childElement, myTree, path -> { }); } myTree.setSelectionPath(new TreePath(rootNode)); myTree.scrollRectToVisible(new Rectangle(new Point(0, 0))); }