First I would say that you are using TreeModel incorrectly if you are modifying the JTree by calling setModel. This should only be used for creating a new JTree. Instead
you should modify your TreeModel and call the reload() method of DefaultTreeModel (which you extended, right?). For a full description and example see:
http://java.sun.com/products/jfc/tsc/articles/jtree/ If you absolutely insist on using the setModel method to update your tree then you could do something like this. Keep track of the expanded paths in a list. Register a TreeExpansionListener that does something like this:
Then after calling setModel iterate through the path list and call expandPath for each one. But, the first option is better.