Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在JavaFX中使用TabPane_Java_Javafx_Tabs_Pane_Graphicscontext - Fatal编程技术网

在JavaFX中使用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();

我正在从使用流程窗格切换到选项卡窗格。我不知道该怎么做。 我想在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();

    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);