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);
}
Tabis not a subclass ofPane, so it has nogetChildren()method.Instead, it has a
contentproperty 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
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: