How to enable a dropdown list of predetermined items to add to a custom control in SceneBuilder?
Asked Answered
N

1

8

The DialogPane has this implementation in SceneBuilder:

You can add to the Pane a list of buttons.

enter image description here

I am looking to do this for my custom control in scenebuilder. I could not find anything obvious inside the constructor for DialogPane that would make this work.

Is doing this a possibility?

private final ObservableList<ButtonType> buttons = FXCollections.observableArrayList();

public DialogPane() {
    getStyleClass().add("dialog-pane");

    headerTextPanel = new GridPane();
    getChildren().add(headerTextPanel);

    graphicContainer = new StackPane();

    contentLabel = createContentLabel("");
    getChildren().add(contentLabel);

    buttonBar = createButtonBar();
    if (buttonBar != null) {
        getChildren().add(buttonBar);
    }
    buttons.addListener((ListChangeListener<ButtonType>) c -> {
        while (c.next()) {
            if (c.wasRemoved()) {
                for (ButtonType cmd : c.getRemoved()) {
                    buttonNodes.remove(cmd);
                }
            }
            if (c.wasAdded()) {
                for (ButtonType cmd : c.getAddedSubList()) {
                    if (! buttonNodes.containsKey(cmd)) {
                        buttonNodes.put(cmd, createButton(cmd));
                    }
                }
            }
        }
    });
}
Nilla answered 4/10, 2017 at 1:11 Comment(1)
Interesting... The place to look to figure out how this works is probably the source code for Scene Builder. You need to figure out if it just treats this property in DialogPane as a special case (in which you are probably out of luck), or if it looks for something specific (a read only property which has a type that has some constants defined of the same type, or something...).Pelton
H
0

You should try clicking in the library-panel on the settings-icon in the top-right corner, then click on Costum Library Folder -> Reveal In Explorer.

For more information, see this tutorial.

Harmonic answered 30/12, 2017 at 10:35 Comment(1)
This control is not custom.Nilla

© 2022 - 2024 — McMap. All rights reserved.