[英]Buttons in TabPane using JavaFX
在查看了“ 向選項卡和選項卡區域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>
結果如下圖所示。
在僅與場景構建器一起工作了數周並在幾個月前針對應用程序的FXML文件工作了幾周之后,我嘗試做類似的事情,但是我沒有成功嘗試做某事,因為我認為頂部的空間如果您要添加一些選項卡,則保留該選項,我解決了將所需的按鈕插入所需選項卡的問題,這是我所做的示例: 在此處輸入圖片描述
希望對您也有幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.