0

I'm switching from using a flowpane to a tabpane. I have no idea how to. I want to use a canvas and a pane within the tabpane is this possible? Below is my code without all the styling etc.

 public View(TabPane root) {
    this.root = root;

    tab1 = new Tab();
    root.getTabs().add(tab1);

    tab2 = new Tab();
    root.getTabs().add(tab2);

    ui = new Pane();

    canvas = new Canvas(600,600);
    //gc is graphics context
    gc = canvas.getGraphicsContext2D();

    //this is where the problem is??
    //i have no idea how to add ui and canvas to my tab1
    tab1.getChildren().addAll(ui, canvas);
}

1 Answers1

0

Tab is not a subclass of Pane, so it has no getChildren() method.

Instead, it has a content property whose value is the node displayed in the tab (note there is only one node in a tab).

So you can display the canvas in the tab with

tab1.setContent(canvas);

and of course if you have two things to display, you would put them in some other container and set the content of the tab to the container:

VBox vbox = new VBox(ui, canvas);
tab1.setContent(vbox);
James_D
  • 201,275
  • 16
  • 291
  • 322