<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>I'm seeing something odd in Control.  It tries to initialize the
      default platform user agent stylesheet in a static initializer. 
      This makes any subclass of Control hard to test (as a unit) as it
      will try to initialize the entire JavaFX platform. <br>
    </p>
    <p>I see little need for this.  The stylesheet is loaded actually in
      3 different places:</p>
    <p>- Control<br>
      - PopupControl<br>
      - Application (if calling <span
        style="background-color:#ffffff;padding:0px 0px 0px 2px;"><span
style="color:#000000;background-color:#ffffff;font-family:"Consolas";font-size:11pt;white-space:pre;"><span
        style="color:#000000;"></span><span
        style="color:#000000;background-color:#d4d4d4;">setUserAgentStylesheet</span></span></span>
      with null)</p>
    <p>Could we perhaps just defer this loading? Or perhaps load it when
      another class is created that is required for CSS processing?</p>
    <p>I could imagine the following options:</p>
    <p>- Initialize this when Window or Scene class is loaded (required
      to make use of CSS)<br>
      - Initialize this somewhere in Application as a default<br>
      - Instead of initializing the whole platform, set only a flag that
      says "A Control class was loaded already, so when platform starts,
      set the stylesheet" (if we're for some reason purposely only doing
      this when a Control class is loaded...)</p>
    <p>I have no idea why this is in Control or PopupControl
      specifically.  If I make an FX application without ever loading
      Control (using Regions for example), should I be surprised that
      Modena styles are not working when I put them on my regions?  What
      if I do apply some style (let's say "button"), should I be
      surprised the behavior changes when I later do create (but not
      use) a Control as then suddenly Modena styles start applying?</p>
    <p>Is there some attempt here to prevent loading of the Modena
      stylesheet when NOT using Controls?<br>
    </p>
    The code in question in Control static initializer is this:<br>
    <br>
    <div style="background-color:#ffffff;padding:0px 0px 0px 2px;">
      <div
style="color:#000000;background-color:#ffffff;font-family:"Consolas";font-size:11pt;white-space:pre;"><p
      style="margin:0;"><span style="color:#000000;">        </span><span
      style="color:#3f7f5f;">// Ensures that the default application user agent stylesheet is loaded</span></p><p
      style="margin:0;"><span style="color:#000000;">        </span><span
      style="color:#0000a0;font-weight:bold;">if</span><span
      style="color:#000000;"> (Application.</span><span
      style="color:#000000;font-style:italic;">getUserAgentStylesheet</span><span
      style="color:#000000;">() == </span><span
      style="color:#0000a0;font-weight:bold;">null</span><span
      style="color:#000000;">) {</span></p><p style="margin:0;"><span
      style="color:#000000;">            PlatformImpl.</span><span
      style="color:#000000;background-color:#d4d4d4;font-style:italic;">setDefaultPlatformUserAgentStylesheet</span><span
      style="color:#000000;">();</span></p><p style="margin:0;"><span
      style="color:#000000;">        }</span></p></div>
    </div>
    <p></p>
    <p>I really see no reason why this code needs to be here
      specifically.  It in fact looks a bit of a hack.</p>
    <p>--John<br>
    </p>
  </body>
</html>