title: How to parse/map JavaFX CSS file to retrieve its properties and values?
body: <p>My application allows users to use custom CSS themes to style the interface.  I have several pre-built "themes" available to choose from that are very simple, with only 3 properties.</p>
  
  <p><strong>Sample CSS:</strong></p>
  
  <pre><code>.root{
      -fx-background: #325c81;
      -fx-default-button: #77a3ca;
      -fx-base: #a7c4dd;
  }
  </code></pre>
  
  <p>The application has 3 <code>ColorPicker</code> controls that need to allow users to select a color for each of those properties and save back to the CSS file.</p>
  
  <p>I have no problem with actually writing the CSS file, but I cannot find a way to parse the <code>.css</code> file in order to set the values of the <code>ColorPicker</code> controls with the values from the <code>.css</code> file.</p>
  
  <p><strong>Basic Program Flow</strong></p>
  
  <p>1) User selects a premade theme from <code>ComboBox</code>:</p>
  
  <pre><code>cboPresetTheme.valueProperty().addListener((observable, priorTheme, newTheme) -&gt; {
                  Utility.applyTheme(cboPresetTheme.getScene(), newTheme);
              });
  </code></pre>
  
  <p>2) The associated <code>.css</code> file is loaded and applied to the current <code>Scene</code>:   </p>
  
  <pre><code>public static void applyTheme(Scene scene, Theme theme) {
      scene.getStylesheets().clear();
  
      File css = new File("themes/" + theme.getFileName());
      File fontFile = new File("themes/Font.css");
  
      scene.getStylesheets().addAll(
              css.toURI().toString(),
              fontFile.toURI().toString());
  }
  </code></pre>
  
  <p>3) The 3 <code>ColorPicker</code> controls are updated with the values from the applied <code>StyleSheet</code>:</p>
  
  <pre><code>cpBackground.setValue(Color.valueOf(cssFileBackground));
  cpBase.setValue(Color.valueOf(cssFileBase));
  cpDefaultButton.setValue(Color.valueOf(cssFileDefaultButton));
  </code></pre>
  
  <p>While I have no problem with steps 1 &amp; 2, I do not know how to process step 3.</p>
  
  <p>I have looked at other CSS Parser libraries (thank you, Google) but they seem more geared toward stand CSS and don't support FX properties. The StackExchange question <a href="https://stackoverflow.com/questions/33776022/javafx-edit-or-parse-fx-css-file-programmatically" title="edit or parse FX-CSS file programmatically">edit or parse FX-CSS file programmatically</a> appears to be asking the same question but it was never successfully answered.</p>
  
  <p>One answer suggests using <a href="http://sourceforge.net/projects/cssparser/" rel="nofollow noreferrer">CSS Parser</a> to accomplish this, but as there is little to know documentation (and what is there is beyond my current comprehension level), I don't know where to begin.</p>
  
  <p>I understand there may not be a standard API currently available to accomplish this, but I was hoping there may be a simple library or solution out there that I have been unable to find.</p>