title: Using java.util.Properties to drive Compose states
body: <p>I am designing a GUI for my desktop application using <a href="https://www.jetbrains.com/lp/compose-mpp/" rel="nofollow noreferrer">Compose for Desktop</a>. Some GUI components need to be preserved if the application is closed and reopened—and some GUI components also need to change based on some state(s). To do this, I am using a simple <code>java.util.Properties</code> object to store information (I have already extended <code>Properties</code> to store its contents to a file whenever <code>setProperty</code> is called).</p>
  <p>For example, I want to have the GUI components update when the locale is changed. When the user changes the locale, I set that property, something along the lines of:</p>
  <pre class="lang-kotlin prettyprint-override"><code>launcherState = Properties() // This is being initialized before the launcher is rendered
  ...
  launcherState.setProperty(&quot;locale&quot;, &quot;en&quot;)
  </code></pre>
  <p>I then want then want a <code>ResourceBundle</code>—defined by a state—to update. I have tried something like this:</p>
  <pre class="lang-kotlin prettyprint-override"><code>val locale by remember { derivedStateOf { launcherState.getProperty(&quot;locale&quot;) } }
  val i18n by remember {
          derivedStateOf {
              ResourceBundle.getBundle(&quot;i18n.launcher&quot;, Locale.forLanguageTag(locale))
          }
      }
  </code></pre>
  <p>The text elements of the GUI use the <code>i18n</code> object to obtain their strings.</p>
  <p>However, if I call <code>launcherState.setProperty(&quot;locale&quot;, &quot;fr&quot;)</code>, <code>locale</code> and <code>i18n</code> do not update (therefore the GUI does not update)—which I believe they shouldn't anyways.</p>
  <p>So my question is, how can I make <code>launcherState</code> &quot;observable&quot; so that when I make a change to it, the states update? Or perhaps, I should be taking a completely different approach.</p>