RFR: 8290844: Add Skin.install() method

Michael Strauß mstrauss at openjdk.org
Mon Aug 8 20:37:50 UTC 2022


On Fri, 22 Jul 2022 19:22:48 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

> - added Skin.install()
> - javadoc changes for Skinnable.setSkin(Skin)
> 
> no code changes for Skinnable.setSkin(Skin) yet.

1. In a property setter, you cannot do anything other than call `property.set(...)`, since `setFoo(...)` and `fooProperty().set(...)` must be equivalent.
2. As you discovered, `ComboBoxPopupControl` implements a skin that violates the `getSkinnable()` specification. But that seems to be completely unnecessary. When I change the implementation to conform to the specification, everything works just as well: all tests pass, and I can run a large application (SceneBuilder) without problems.

Here's the code in `ComboBoxPopupControl` that I've tested:

private void createPopup() {
    class PopupControlImpl extends PopupControl {
        @Override public Styleable getStyleableParent() {
            return ComboBoxPopupControl.this.getSkinnable();
        }

        PopupControlImpl() {
            setSkin(new Skin<>() {
                @Override public Skinnable getSkinnable() { return PopupControlImpl.this; }
                @Override public Node getNode() { return getPopupContent(); }
                @Override public void dispose() { }
            });
        }
    }

    popup = new PopupControlImpl();
    ....
}

modules/javafx.controls/src/main/java/javafx/scene/control/PopupControl.java line 269:

> 267:             if(skin != null) {
> 268:                 skin.install();
> 269:             }

You should probably also add the check for PopupControl.

-------------

PR: https://git.openjdk.org/jfx/pull/845


More information about the openjfx-dev mailing list