• Post Reply Bookmark Topic Watch Topic
  • New Topic

Add new node value to array

 
shobhitgup gupta
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an add button on my screen to add a new node to tree. So once we click add button a popup comes to provide the new node name and then we press add button and the new node gets added to the tree.So know i want that when ever we add a new node to the tree the value of the new node should get stored in an array at the same time.

How can we achieve this. Any help would be much appreciated.

Thanks,
Shobhit
 
Stephan van Hulst
Bartender
Posts: 6583
84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Shobhitgup, welcome to CodeRanch.

You're approaching the problem the wrong way around. Why not add a node to your array, and give your JTree a custom model that monitors this array. Then whenever you update the array, the tree will get updated automatically.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!