# Capture Tree View State

**URL:** <https://forum.inductiveautomation.com/t/capture-tree-view-state/5138>\
**Category:** Ignition\
**Created:** [September 12, 2012, 9:46pm UTC](https://forum.inductiveautomation.com/t/capture-tree-view-state/5138 "2012-09-12T21:46:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [September 12, 2012, 9:46pm UTC](https://forum.inductiveautomation.com/t/capture-tree-view-state/5138/1 "2012-09-12T21:46:29Z")

</div>

Is there a tree view property I can capture that holds the state of which nodes are expanded? I have a tab and tree navigation setup i am working on and when I switch between tabs the tree item data changes. when i switch back to an already visited tab the tree goes back to the original state. I was hoping i could hold the state in a property and assign it back to the tree when returning to a tab.

Thank you,

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [September 12, 2012, 11:24pm UTC](https://forum.inductiveautomation.com/t/capture-tree-view-state/5138/2 "2012-09-12T23:24:59Z")

</div>

Not really. “Remembering” tree expansion state is a bit hairy. You’d have to get the underlying JTree, ask it for the tree paths that are expanded, store them, and then when appropriate, try and expand those paths again. Check out the JavaDocs for JTree: [docs.oracle.com/javase/6/docs/ap … JTree.html](http://docs.oracle.com/javase/6/docs/api/javax/swing/JTree.html)

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [September 13, 2012, 5:20pm UTC](https://forum.inductiveautomation.com/t/capture-tree-view-state/5138/3 "2012-09-13T17:20:44Z")

</div>

It is not clear to me how to get the JTree out of the PMITreeView. I use the dir(tree. **class** ) to see what methods were available, but i do not see any that sound like they would give me the JTree.

Thanks for the help,

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [September 13, 2012, 6:01pm UTC](https://forum.inductiveautomation.com/t/capture-tree-view-state/5138/4 "2012-09-13T18:01:37Z")

</div>

You can get the JTree by getting the component instance however you like, and then calling getViewport().getView() on it:

```auto
getComponentInstance().getViewport().getView()
```
