[REVIEW REQUEST] RT-25325 Controls should be hardcoded to their default skin in case -fx-skin is not specified in CSS

Jasper Potts jasper.potts at oracle.com
Thu Nov 22 07:08:58 PST 2012


Only during CSS application so that we can give CSS a chance first at setting the skin. 

Jasper

Sent from my iPhone

On Nov 22, 2012, at 5:33 AM, Richard Bair <richard.bair at oracle.com> wrote:

> I like this idea. Is the createDefaultSkin method called from the constructor, or only during the CSS application phase?
> 
> Richard
> 
> On Nov 21, 2012, at 9:17 PM, Jasper Potts <jasper.potts at oracle.com> wrote:
> 
>> Hi all, 
>> 
>> When building applications we often want to remove and replace all the default styling from a control but still use the default skin. To do this so far you had to respecify the default skin in your css file with something like
>> 
>> .my-button {
>>    -fx-skin: "com.sun.javafx.scene.control.skin.ButtonSkin";
>> }
>> 
>> The problem with this is the skins are in a com.sun package so not public API and may change in the future. So what I propose doing is adding new protected method to Control class so that sub-classes can create instances of their default skin. 
>> 
>> public abstract class Control{
>> …...
>>   /**
>>    * Create a new instance of the default skin for this control. This is called to create a skin for the control if
>>    * no skin is provided via CSS {@code -fx-skin} or set explicitly in a sub-class with {@code  setSkin(...)}.
>>    *
>>    * @return  new instance of default skin for this control. If null then the control will have no skin unless one
>>    *          is provided by css.
>>    */
>>   protected Skin<?> createDefaultSkin() ….
>> ….
>> }
>> 
>> The reason for returning a instance rather than class name string is it speeds up start up to not have to do the reflection to lookup and instantiate the class from classname. It would have been nice if this could have been a abstract method but that would have not been backwards compatible.
>> 
>> All existing code will work as it does not but any css specifying the default skin can now be removed when running on 8.
>> 
>> Thanks
>> 
>> Jasper
> 


More information about the openjfx-dev mailing list