D
Duane Evenson
Forgive the newbe level of this question.
I have define and declare a root node, jtree and model. I add nodes to the
model. The tree doesn't get updated.
Why?
I thought insertNodeInto fired tree updates.
I have to use model.reload() to update the tree.
TIA
Duane
Here's my test code:
//-------------------------------------
import javax.swing.*;
import javax.swing.tree.*;
public class TestTree {
public static void main(String[] args) {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("top");
JTree tree = new JTree(root);
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
for (int x = 1; x <= 10; x++) {
model.insertNodeInto(new DefaultMutableTreeNode("node " + x),
root, root.getChildCount());
}
//model.reload();
JFrame frame = new JFrame();
frame.add(tree);
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
I have define and declare a root node, jtree and model. I add nodes to the
model. The tree doesn't get updated.
Why?
I thought insertNodeInto fired tree updates.
I have to use model.reload() to update the tree.
TIA
Duane
Here's my test code:
//-------------------------------------
import javax.swing.*;
import javax.swing.tree.*;
public class TestTree {
public static void main(String[] args) {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("top");
JTree tree = new JTree(root);
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
for (int x = 1; x <= 10; x++) {
model.insertNodeInto(new DefaultMutableTreeNode("node " + x),
root, root.getChildCount());
}
//model.reload();
JFrame frame = new JFrame();
frame.add(tree);
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}