我使用默认的NetBeans edito创建了一个表单并将其jTree
放在上面。然后以某种方式在其中创建一堆元素,例如“颜色”,“运动”,“食物”。但是它不在创建代码中。它来自哪里,如何编辑...
即使我做的jTree1.removeAll();
一切仍然存在...并且没有将代码添加到jTree的代码。
private void test(java.awt.event.MouseEvent evt) {
//trying to remove all, but it does not remove anything
jTree1.removeAll();
//it does print it in debug meaning that this function is called
System.out.println("qwe");
//create the root node
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
//create the child nodes
DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("Child 1");
DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("Child 2");
//add the child nodes to the root node
root.add(child1);
root.add(child2);
//now how do I add it to the tree?
//???
}
我需要能够jTree
在运行时编辑内容。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句