TreeModel mod = tree.getModel(); setModel(mod); if (mod != null) { Object root = mod.getRoot(); if (root != null) { TreePath path = new TreePath(root); if (!tree.isExpanded(path)) toggleExpandState(path); } }
setModel(tree.getModel());
  public void installUI(JComponent c)  {    tree = (JTree) c;    prepareForUIInstall();    super.installUI(c);    installDefaults();    installComponents();    installKeyboardActions();    installListeners();    setCellEditor(createDefaultCellEditor());    createdCellEditor = true;    isEditing = false;        TreeModel mod = tree.getModel();    setModel(mod);    if (mod != null)      {        Object root = mod.getRoot();        if (root != null)          {            TreePath path = new TreePath(root);        if (!tree.isExpanded(path))          toggleExpandState(path);      }      }    treeSelectionModel = tree.getSelectionModel();    completeUIInstall();  }