简体   繁体   中英

Jtree node addition

JTree created by me populates from databases. I want to add new node which I am able to create insertNodeInto() function. Now how do I change the underlying database?

  1. Add node first via treemodel and then do the insert in database
  2. Insert into database and then recreate the tree.

I would like to know the steps involved in case (1) above as the tree I created has large number of nodes.

I would add it first to the database. The reason is that if the DB insert fails for some reason (constraints for example) and you get an SQLException, the user should not get the impression that the insert was successful.

Of course, you don't need to recreate the tree, you can just add another node at any time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM