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.
April 25th, 2010 at 22:52
[...] Creating custom controls – the right way‘, ‘JavaFX: Bounds by example‘, ‘JavaFX: Gotcha in skin assignment‘ and ‘JavaFX 1.3: Binding [...]