title: Reusable constants for FXML layouts?
body: <p>This is somewhat a follow up to my previous <a href="https://stackoverflow.com/q/51146953/8555967">question</a>. Somehow, I got the solution for my question from <a href="https://stackoverflow.com/a/51060866/8555967">here</a>, but it never really answered my question for some reasons, which led me to ask this question.</p>
  
  <p>Here's the reason why:</p>
  
  <ul>
  <li>I found out that by using the <code>FXMLLoader.namespace</code>, the mapped values are only accessible for the layout (FXML file) which the FXMLLoader is being loaded. This doesn't met the desire of having reusable <em>constants</em> for other FXML files though.</li>
  <li>Additionally, since these <em>constants</em> are defined in a Java code, it is considered an error by the IDE when used because they are not directly defined within the FXML file, which then becomes hard to track down other exceptional errors.</li>
  </ul>
  
  <p>So the question now is, how to make <em>constants</em> reusable for FXML layouts?</p>
  
  <p>Like in Android, a <a href="https://developer.android.com/guide/topics/resources/more-resources#Color" rel="nofollow noreferrer">Color resource</a> for example:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
    &lt;color name="white"&gt;#FFFFFF&lt;/color&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>Can be applied to an XML layout's attribute:</p>
  
  <pre><code>android:textColor="@color/white"
  </code></pre>
  
  <p>Is there any other possible way in JavaFX? Thanks for all answer.</p>