0

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.

Vin
  • 701
  • 1
  • 9
  • 30
  • 3
    One code snippet is better than thousand words. – Nikolas Charalambidis Sep 26 '17 at 18:15
  • It's difficult to add a code snipped, I'd to add the whole code of a skin in the package I mentioned. – Vin Sep 26 '17 at 18:18
  • 2
    Please ask a single, clear, unambiguous question, providing an [mcve](https://stackoverflow.com/help/mcve) to demonstrate the issues. If there are multiple issues and questions, then ask multiple questions. At the moment it is unclear what anybody would respond to this who wished to answer - I don't think a true answer is reasonably possible at the moment as the question is currently phrased. – jewelsea Sep 26 '17 at 19:08
  • 1
    I imagine customizing a TextField is simpler than customizing a ColorPicker. Can you include a short code-based example of the TextField customization you wish to perform? – VGR Sep 26 '17 at 19:08

0 Answers0