【发布时间】:2013-04-07 10:40:03
【问题描述】:
我正在尝试在 java swing 中创建一个 JTree,现在我想在运行时更改节点文本
try
{
int a=1,b=2,c=3;
DefaultMutableTreeNode root =
new DefaultMutableTreeNode("A"+a);
DefaultMutableTreeNode child[]=new DefaultMutableTreeNode[1];
DefaultMutableTreeNode grandChild[]= new DefaultMutableTreeNode[1];
child[0] = new DefaultMutableTreeNode("Central Excise"+b);
grandChild[0]=new DefaultMutableTreeNode("CE Acts: "+c);
child[0].add(grandChild[0]);
root.add(child[0]);
tree = new JTree(root);
}
catch(Exception ex)
{
ex.printStackTrace()
}
现在我想知道如何在子节点和大子节点中以类似方式动态地将 A 1 更改为 2
【问题讨论】: