void (TreeExpansionEvent event) { TreePath path = event.getPath(); TreeModel model = tree.getModel(); Object lastPathComponent = path.getLastPathComponent(); if (model.getChildCount(lastPathComponent) == 1) { TreePath firstChildPath = path.pathByAddingChild(model.getChild(lastPathComponent, 0)); tree.expandPath(firstChildPath); } }