我正在尝试在 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