在JavaFX中使用TabPane
我正在从使用流程窗格切换到选项卡窗格。我不知道该怎么做。 我想在tabpane中使用画布和窗格这可能吗? 下面是我的代码,没有所有的样式等在JavaFX中使用TabPane,java,javafx,tabs,pane,graphicscontext,Java,Javafx,Tabs,Pane,Graphicscontext,我正在从使用流程窗格切换到选项卡窗格。我不知道该怎么做。 我想在tabpane中使用画布和窗格这可能吗? 下面是我的代码,没有所有的样式等 public View(TabPane root) { this.root = root; tab1 = new Tab(); root.getTabs().add(tab1); tab2 = new Tab(); root.getTabs().add(tab2); ui = new Pane();
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);
}
不是窗格
的子类,因此它没有getChildren()
方法
相反,它的值是选项卡中显示的节点(请注意,选项卡中只有一个节点)
因此,您可以在选项卡中使用
tab1.setContent(canvas);
当然,如果要显示两个内容,可以将它们放在其他容器中,并将选项卡的内容设置为容器:
VBox vbox = new VBox(ui, canvas);
tab1.setContent(vbox);