[REVIEW REQUEST] RT-19713 Add API to JavaFX to allow for setting preferred user agent stylesheet

Jim Weaver james.weaver at oracle.com
Wed Nov 21 13:47:43 PST 2012

Jonathan, Jasper, et al,

I like this approach for the reason that the latest and greatest style 
is applied by default, unless the developer/organization has a 
preference for a particular (e.g. Caspian, or custom) stylesheet.

Jim Weaver

On 11/21/12 4:29 PM, Jonathan Giles wrote:
> I think the comment in Jaspers code is very important to pull out and 
> highlight, as what he says in the javadoc comment is exactly what I 
> want. In short, my personal preference is to push for JavaFX to 
> upgrade to new user agent stylesheets _by default_. I mentioned this 
> issue in RT-19713, but I'm keen to discuss this more widely.
> The benefit of this approach is that it would prevent the issue we had 
> in Swing where the default look remained as Metal forever - which 
> didn't really help Swing take the world by storm. Many months ago 
> Jasper started investigating a new CSS style and I was helping to give 
> feedback. The reason I mention this is that immediately the new style 
> made the current Caspian style look dated and heavy, in my opinion 
> (which is pretty impressive as Caspian doesn't look bad by any means). 
> I would upgrade my personal applications to the new look in a 
> heartbeat, and I would love to have all JavaFX applications upgrade to 
> this as well - rather than be stuck on Caspian.
> Of course, just because we update by default doesn't mean that this is 
> what people necessarily want for their software - they want to be 
> certain we don't break their apps when the styles change. To allow for 
> this, developers would have to explicitly state (using the API Jasper 
> has outlined below) what style they want to use.
> In other words, I would like us to switch from opt-in to opt-out (of 
> new styles), and I'd be very keen to hear feedback on this in 
> conjunction with the feedback Jasper is seeking.
> -- Jonathan
> On 22/11/2012 10:09 a.m., Jasper Potts wrote:
>> Hi All,
>> I would like to add API to Application to add the ability to set the 
>> default user agent stylesheet. So far JavaFX has had a default 
>> stylesheet of capsian.css hard coded for all applications. In 8 if we 
>> have time I would like to have a new stylesheet that you can use as 
>> alternative to caspian.css. This would also open the platform to easy 
>> use of 3rd party look and feels.
>> public abstract class Application {
>> ….
>>      /**
>>       * Set the default user agent stylesheet. This is used to 
>> provide default
>>       * styling for all ui controls and other nodes. Each release of 
>> JavaFX may
>>       * have a new default value for this so if you need to guarantee 
>> consistency
>>       * you will need to call this method and choose what default you 
>> would like
>>       * for your application.
>>       *
>>       * @param url The URL to the stylesheet as a String.
>>       */
>>      public static void setDefaultUserAgentStylesheet(String url) ….
>> …..
>> }
>> This has been a much requested feature for a long time:
>> http://javafx-jira.kenai.com/browse/RT-8054
>> http://javafx-jira.kenai.com/browse/RT-5753
>> http://javafx-jira.kenai.com/browse/RT-19713
>> There have been some workarounds for specific use cases and a 
>> proposed solution for a Theme class but none have solved the root 
>> problem of being able to change the default user agent stylesheet.
>> Thanks
>> Jasper

Jim Weaver
Java Evangelist
Oracle Corporation
james.weaver at oracle.com

More information about the openjfx-dev mailing list