JTree获取所选中节的点文字,假设JTree变量为jtree如下:
jtree.addTreeSelectionListener(new TreeSelectionListener(){
@Override
public void valueChanged(TreeSelectionEvent e) {
// TODO Auto-generated method stub
DefaultMutableTreeNode selectedNode=(DefaultMutableTreeNode) treelist.getLastSelectedPathComponent();//返回最后选定的节点
String sel = selectedNode.toString(); //获取选中的节点文字
}
});