JavaFX: Gotcha in Skin assignment…

When assigning a new skin in the object literal of the control, it may be ignored if the control doesn’t take care of it.

Instead of the commonly used code:
[cc lang="c"]
override function create(): Node {
skin = MyOwnControlSkin { };
super.create();
}
[/cc]

it is necessary to check whether a skin has already been set:

[cc lang="c"]
override function create(): Node {
if ( skin == null ){
skin = MyOwnControlSkin { };
}

super.create();
}
[/cc]

I think the API should be improved! What about some kind of default skin? Abstract method? Function? Field?

I have updated the template accordingly.


One Response to “JavaFX: Gotcha in Skin assignment…”

Leave a Reply