可以使用以下方法获取当前节点的深度: ```java int depth = tree.getPathForRow(tree.getSelectionRows()[0]).getPathCount() - 1; ``` 其中,`tree.getSelectionRows()[0]`获取当前选中节点的行号,`tree.getPathForRow(row)`获取该行对应的树路径,`getPathCount()`获取树路径中的节点数,减去1即为当前节点的深度。