void (JTree tree) { TreePath[] paths = tree.getSelectionPaths(); if (paths == null) { paths = new TreePath[] { new TreePath(tree.getModel().getRoot()) }; } for (TreePath path : paths) { new ExpandContext(300, 10).expand(tree, path); } }