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. 

I see little need for this.  The stylesheet is loaded actually in 3
different places:

- Control
- PopupControl
- Application (if calling setUserAgentStylesheet with null)

Could we perhaps just defer this loading? Or perhaps load it when
another class is created that is required for CSS processing?

I could imagine the following options:

- Initialize this when Window or Scene class is loaded (required to make
use of CSS)
- Initialize this somewhere in Application as a default
- 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...)

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?

Is there some attempt here to prevent loading of the Modena stylesheet
when NOT using Controls?

The code in question in Control static initializer is this:

// Ensures that the default application user agent stylesheet is loaded

if(Application.getUserAgentStylesheet() == null) {

PlatformImpl.setDefaultPlatformUserAgentStylesheet();

}

I really see no reason why this code needs to be here specifically.  It
in fact looks a bit of a hack.

--John

Reply via email to