The following code although compiles without error, does not expand the nav tree to show the newly inserted node. What am I doing wrong here?
VCmpNavTreeNode savedNode = curHandler.requestSaveNavTreeNode( treeNode );
// Check that the returned node has been properly saved by
// checking that the Node is not null
if ( savedNode != null ) {
successfulSave = true;
JTree navTree = parentViewDu.getTree();
DefaultTreeModel navTreeModel = (DefaultTreeModel)
navTree.getModel();
if (editPolicy == Constants.Gen_AsNew) {
// For new, first build a new Node Object with
// all default blank values
// If saved, then add to tree
navTreeModel.insertNodeInto(
treeNode, parentTreeNode,
parentTreeNode.getChildCount()
);
// XXX This expansion doesn't work - don't know why !
// Get the index of the parentNode, and
// then expand the tree for the current index
int i =
navTreeModel.getChildCount
(this.parentTreeNode) - 1;
TreeNode[] theNodes = navTreeModel.getPathToRoot(
(TreeNode) navTreeModel.getChild(
this.parentTreeNode, i
)
);
TreePath theNodePath = new TreePath(theNodes);
navTree.expandPath(theNodePath);
navTree.repaint();
Thanks for any help in advance.
Snowcrash
VCmpNavTreeNode savedNode = curHandler.requestSaveNavTreeNode( treeNode );
// Check that the returned node has been properly saved by
// checking that the Node is not null
if ( savedNode != null ) {
successfulSave = true;
JTree navTree = parentViewDu.getTree();
DefaultTreeModel navTreeModel = (DefaultTreeModel)
navTree.getModel();
if (editPolicy == Constants.Gen_AsNew) {
// For new, first build a new Node Object with
// all default blank values
// If saved, then add to tree
navTreeModel.insertNodeInto(
treeNode, parentTreeNode,
parentTreeNode.getChildCount()
);
// XXX This expansion doesn't work - don't know why !
// Get the index of the parentNode, and
// then expand the tree for the current index
int i =
navTreeModel.getChildCount
(this.parentTreeNode) - 1;
TreeNode[] theNodes = navTreeModel.getPathToRoot(
(TreeNode) navTreeModel.getChild(
this.parentTreeNode, i
)
);
TreePath theNodePath = new TreePath(theNodes);
navTree.expandPath(theNodePath);
navTree.repaint();
Thanks for any help in advance.
Snowcrash