0

My custom node:

public class Base extends Control {

    private ObjectProperty<Node> content;

    public final void setContent(Node value) {
        contentProperty().set(value);
    }

    public final Node getContent() {
        return content == null ? null : content.get();
    }

    public final ObjectProperty<Node> contentProperty() {
        if (content == null) {
            content = new SimpleObjectProperty<Node>(this, "content");
        }
        return content;
    }

}

And here's how it looks like in Scene Builder: https://i.stack.imgur.com/WfDrf.jpg

Original ScrollPane in Scene Builder: https://i.stack.imgur.com/KFPrX.jpg

I don't understand it, the same code is used in ScrollPane and it works there.

Is it a Scene Builder's bug?

  • 1
    I'm not sure, but I think that scenebuilder processes some kind of stuff for a specific known components. So it cannot be done for custom components. For example for GridPane shows row and column indices. – Tix May 16 '20 at 14:23
  • What should it be? What error are you getting, this is way to obscure. – matt May 16 '20 at 14:27
  • @matt I'd like to be able to add a node (ObjectProperty) to my custom's component named Base. Right now I'm unable to do anything in Scene Builder. – ImNotARobot May 16 '20 at 14:29
  • What does the fxml for your custom component look like? – matt May 16 '20 at 14:35
  • Looking at this blog post, https://rterp.wordpress.com/2014/05/21/adding-custom-javafx-components-to-scene-builder-2-0/ some of the comments seem to indicate you need to add you control as a jar file. Maybe it is outdated though. – matt May 16 '20 at 14:57
  • @matt My components don't have FXML files. The jar tips don't help though – ImNotARobot May 16 '20 at 15:58
  • @matt i use them this way: – ImNotARobot May 16 '20 at 15:58
  • This question also says you need to build your control to use it in scenebuilder. https://stackoverflow.com/questions/30063792/adding-a-custom-component-to-scenebuilder-2-0 – matt May 16 '20 at 16:30
  • @matt I can see my custom node in scene builder, the problem is, i can't add a node to an ObjectProperty in scene builder, so i cant work in this tool. I guess I'll have to code manually – ImNotARobot May 16 '20 at 17:21
  • I think this is a limitation of Scene Builder—it doesn't know how to interpret your property (and there's no way to tell it how). I've noticed the same problem with custom controls even from _ControlsFX_, but maybe I've just been missing something all this time. – Slaw May 16 '20 at 17:54
  • Does annotating `Base` with `@DefaultProperty("content")` help at all? – Slaw May 16 '20 at 17:55
  • @Slaw No, it doesn't – ImNotARobot May 16 '20 at 18:15

0 Answers0