I use JTree with TreeNode which extending DefaultMutableTreeNode.when I add new node,i cant update JTree.Any help will be appreciated
I use JTree with TreeNode which extending DefaultMutableTreeNode.when I add new node,i cant update
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Adding to the node only is not enough, the Tree needs to be notified. The correct way to do this is to let the model take care of adding/removing nodes, as it will notify correctly the Tree on the way.
In case of a DefaultTreeModel (which should be the one used in the JTree if you haven’t made your own TreeModel), you have the method insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index), which you can use.