看了“ 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)
结果如下图所示。