使用 JavaFX 的 TabPane 中的按钮

Mic*_*mer 2 java javafx javafx-8

JavaFX 8 中有没有办法将按钮放入 TabPane 中,如下面的模型所示?如果可能,我只想使用 FXML 文件。 小样

Mic*_*mer 5

看了“ Add Buttons to Tabs and Tab area JavaFX ”的问答后,不难适应它适用于FXML文件。

<AnchorPane prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mypackage.Controller">
    <children>
        <TabPane tabClosingPolicy="UNAVAILABLE" AnchorPane.topAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.bottomAnchor="0.0">
            <tabs>
                /* the code for the tabs goes here */
            </tabs>
        </TabPane>
        <HBox AnchorPane.topAnchor="1.0" AnchorPane.rightAnchor="5.0">
            <children>
                <Button text="Export..." />
                <Button text="Generate" />
            </children>
        </HBox>
    </children>
</AnchorPane>
Run Code Online (Sandbox Code Playgroud)

结果如下图所示。

在此处输入图片说明