With the release of Java JDK 9, as stated by JEP 253, classes related to JavaFX skins of controls are moved from private package com.sun.javafx.scene.control.skin
to the public one javafx.scene.control.skin
.
The reason for that change is developers used to program their custom control, despite Oracle descouraged this practice, subclassing the skin of the private package. So, by moving these classes into a public package, Java now offer a public API to skin a custom control.
But, things are not so simple. I found several problems that I'd like that someone can justify.
The first problem is that, although now there is the public package javafx.scene.control.skin
, there is no public API to modify or customize a skin.
It's simple create a simple button (it was simple also by subclassing the abstract class SkinBase
) but it's very frustating to customize a ColorPicker
or a TextField
or a more complex control. The problem is that we developers have no access to simpler components that compose the complex compound control.
Add the fact that reflection is very hard to use with the introduction of the new module system, it means that apart from a simple custom button or another simple control, it's very very hard to work with the Skin API.
The second problem I found is a bug in the ComboBoxPopupControl
class. I wanted to create a customized version of a ColorPicker
so I create a class that extended ColorPickerSkin
. As a just said, I found very difficult to work with this class, so I make my class to extend the ComboBoxPopupControl
(a direct sublcass of ColorPickerSkin
) that I found more clean to create from the basis my custom color picker. But this class has a bug, it raises a NullPointerException
beacuse a variable, with package private visibility, is not initialized. This variable is of type ColorPickerBehaviour
, that, in Java 8 was possible to initialize it by passing the vaule in the constructor, constructor that in Java 9 does not accept a parameter of that type.
I'd like to know if you worked or are working, like me, using this API of JavaFX, what decision have you taken or what solution have you found.