Swing uses MVC architecture.
So data contained in the tree and the logic for rendering are completely decoupled and independent.
You can simply change contents of the tree without worrying using this Oracle Tutorial.
Just don't forget to call revalidate()
and repaint()
method after updating.
Good luck.