简体   繁体   English

使用JavaFX的TabPane中的按钮

[英]Buttons in TabPane using JavaFX

Is there a way in JavaFX 8 to put buttons into a TabPane as shown in the mockup below? JavaFX 8中是否可以将按钮放入TabPane中,如下面的模型所示? If it is possible, I only want to use a FXML file. 如果可能,我只想使用FXML文件。 小样

After looking at the question and answer of " Add Buttons to Tabs and Tab area JavaFX ", it was not difficult to adapt it that it works with a FXML file. 在查看了“ 向选项卡和选项卡区域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>

The result is shown in the picture below. 结果如下图所示。

在此处输入图片说明

After working several weeks only with the scene builder and on the FXML file for an application a few months ago, i tried to do a similar thing but i didn't succeed in trying a way to do it because i think that space on the top is reserved if you want to add some tabs, i solved my matter in inserting in the desired tabs the buttons i would had there, here is an example of what i did: enter image description here 在仅与场景构建器一起工作了数周并在几个月前针对应用程序的FXML文件工作了几周之后,我尝试做类似的事情,但是我没有成功尝试做某事,因为我认为顶部的空间如果您要添加一些选项卡,则保留该选项,我解决了将所需的按钮插入所需选项卡的问题,这是我所做的示例: 在此处输入图片描述

I hope it is useful to you too 希望对您也有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM