デフォルトの NetBeans 編集でフォームを作成し、その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
実行時にコンテンツを編集できる必要があります。