2

I'm migrating an application containing JavaFX 2 to OpenJDK11. I have an error due to disappearance of inheritance of SkinBase with StackPane. I can't use anymore methods like event methods (defined in Node), getChildren() (defined in Parent) and many others that require inheritence...

This my previous Class in Java 1.7, that I want in JDK11 :

public class WellPlateSkin<T> extends SkinBase<WellPlate, WellPlateSkin.DummyBehaviour>
{
    public WellPlateSkin(final WellPlate control) {
        super(control, new DummyBehaviour(control));
...
setOnMouseDragged(new EventHandler<MouseEvent>()
        {
            @Override
            public void handle(MouseEvent mouseEvent)
            {
                dragging = true;
                onMouseDragged(mouseEvent);

            }
        });
        setOnMousePressed(new EventHandler<MouseEvent>()
        {
            @Override
            public void handle(MouseEvent mouseEvent)
            {
                mousePressed = new Point2D(mouseEvent.getX(), mouseEvent.getY());
                getChildren().add(glass);
                removeSelection();
                rubber.setHeight(0);
                rubber.setWidth(0);
                dragging = false;
            }
        });

        setOnMouseReleased(new EventHandler<MouseEvent>()
        {
            @Override
            public void handle(MouseEvent mouseEvent)
            {
                if (!dragging) {
                    selectNode(new Point2D(mouseEvent.getX(),mouseEvent.getY()));

                }
                mousePressed = null;
                getChildren().remove(glass);
                dragging =false;
            }
        });

These methods inherit from Class Node or Parent That's worked because the signature of SkinBase was (before JavaFX8) :

public abstract class SkinBase<C extends Control, B extends BehaviorBase<C>> extends StackPane implements Skin<C> { 

And StackPane is a child of Pane which is a child of Region which is a child of Parent and which is a child of Node.

Now, in JDK11, the signature of SkinBase is

public abstract class SkinBase<C extends Control> implements Skin<C> {

The Inheritence doesn't exist anymore and these functions are no more defined (the super() neither). What is the best way to sovle this issue ? Thank you for your answer !

pacataque
  • 130
  • 12
  • Thank you for your answer. The only thing I found on internet is that : https://wiki.openjdk.java.net/display/OpenJFX/UI+Controls+Architecture (Change #1: Inheritance hierarchy) The error I have is that the methode is not defined, and that seems logical. So I had to use JavaFX2.x with my Java 1.7 (post updated, sorry). I don't know how to explain better my problem, just my program worked fine before migration and due to the disappearance of inheritance of SkinBase with StackPane, some methods is unaccessible now and I don't know what is the best thing to solve it. – pacataque Sep 25 '19 at 07:08
  • no offense meant, but your description doesn't make sense (as @fabian already noted, though not so blunt ) You either provide a code - that's our common language - example of what you mean or your question will be closed (most probably) – kleopatra Sep 25 '19 at 09:50
  • Ok thank for that, I tried to be more precise, I hope it can help you – pacataque Sep 25 '19 at 10:35
  • hmm .. quite a change of signature (as of fx 8, before it wasn't available or internal, can't remember which probably is why your wording sounded like nonsense, sry, padding back :) - so what you have to do is to compare the evolution of some concrete core skin over versions and do the same in your custom skin. You knew this might happen, using hidden api which might change without much notice :) – kleopatra Sep 25 '19 at 10:45
  • To add event handlers (e.g. `onMouseDragged`) you would just add them to the control directly, rather than through the skin. The `SkinBase` class has a `getChildren()` method that simply returns the child-list of the `Control`. I'm not positive what `selectNode` does, but I'm assuming it selects the top-most node at the given coordinates; if so, see [`MouseEvent#getPickResult()`](https://openjfx.io/javadoc/13/javafx.graphics/javafx/scene/input/MouseEvent.html#getPickResult()). – Slaw Sep 25 '19 at 12:23
  • @Slaw just guessing (don't have such an old version with such an abominable api design handy): the old skinBase (== stackPane) probably was added as child to the control - if so, the easiest way out would be to create a stackPane, add it as child and let it handle the input events, not much change needed in that part. But with so many moving bullets (like the advent of behavior) there's much work and pain ahead .. – kleopatra Sep 25 '19 at 12:40

0 Answers0