2015-12-15

Swing reload JTree

So many people want to know how a JTree in for example a JScrollPane can be reloaded. To make it short, no revalidating, no repainting by hand - just:

 DefaultTreeModel model = (DefaultTreeModel)getModel();
 model.reload();

Call this everytime your underlying data changes and the view will update itself automatically. This is mainly for myself, because I have to look it up again every time I need it...