# Value Tree In Application

**URL:** <https://forum.juce.com/t/value-tree-in-application/53995>\
**Category:** General JUCE discussion\
**Created:** [December 4, 2022, 3:18pm UTC](https://forum.juce.com/t/value-tree-in-application/53995 "2022-12-04T15:18:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robParkie](https://avatars.discourse-cdn.com/v4/letter/r/f6c823/32.png) [@robParkie](https://forum.juce.com/u/robParkie)\
**Post date:** [December 4, 2022, 3:18pm UTC](https://forum.juce.com/t/value-tree-in-application/53995/1 "2022-12-04T15:18:17Z")

</div>

Hello

I have a really simple application and I need to save an IP address and port number for next time its opened. I was going to do this in a value tree. I have used value trees in plug ins before and was surprised to find that it is different in applications. iv had a read of the tutorial doc but im not getting anywhere, much of the example code in the tutorial doc throws errors.

I am aware that I need to create a value tree and then attach a listener to my text box (Label) but I can’t work out how to get that far. once I have that I should be able to create and recall XMLs its just im falling at the first hurdle. Any one able to give me a few step by step pointers?

---

<div class="post-metadata">

**Author:** ![refusesoftware](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/refusesoftware/32/20561_2.png) [@refusesoftware](https://forum.juce.com/u/refusesoftware)\
**Post date:** [December 4, 2022, 4:41pm UTC](https://forum.juce.com/t/value-tree-in-application/53995/2 "2022-12-04T16:41:55Z")

</div>

Rather than use a separate listener, and wiring up the connection between a ValueTree property and a GUI component yourself, I would recommend using JUCE’s [PropertyComponents](https://docs.juce.com/master/classPropertyComponent.html).

There are several subclasses of these. For an IP address and port number I’d guess you’d want the [TextPropertyComponent](https://docs.juce.com/master/classTextPropertyComponent.html) (although if you wanted the user to choose from only a set number of options, you could instead use a ChoicePropertyComponent).

When you construct a PropertyComponent, you can give it a `Value& valueToControl`, which you can get from the ValueTree for a property using `ValueTree::getPropertyAsValue`.

Then the GUI and the ValueTree property connection is maintained by the PropertyComponent, and you don’t have to wire up your own listener scheme.

---

<div class="post-metadata">

**Author:** ![jcomusic](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jcomusic/32/2014_2.png) [@jcomusic](https://forum.juce.com/u/jcomusic)\
**Post date:** [December 5, 2022, 9:57am UTC](https://forum.juce.com/t/value-tree-in-application/53995/3 "2022-12-05T09:57:45Z")

</div>

There may be an argument for implementing a scheme that is similar to the APVST attachments if concurrency is involved or if additional smartness is required for handling an undo manager, or if additional validation should be performed. For the simple cases PropertyComponent looks like a good approach though.
