tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { if(!tree.isSelectionEmpty()) { //判断节点是否被选中,被选中为0,没被选中为1 TreePath[] selectionPath = tree.getSelectionPaths();//获取所有被选中节点的路径 StringB