Javafx如何动态地将内容添加到fxml文件中的现有选项卡(Javafx how to add content to an existing tab in fxml file dynamically

编程入门 行业动态 更新时间:2024-10-27 20:25:55
Javafx如何动态地将内容添加到fxml文件中的现有选项卡(Javafx how to add content to an existing tab in fxml file dynamically)

我已经看到很多关于如何将新TAB添加到fxml文件的现有选项卡窗格的答案。 我需要将内容添加到选项卡窗格的已经存在的选项卡中。 可能吗? 如果是,我该怎么做?

I have seen a lot of answers on how to add a NEW TAB to an existing tab pane of fxml file. I need to add content to an already EXISTING TAB of a tab pane. Is it possible? If yes how do I do that?

最满意答案

当然有可能。 请按照以下步骤操作:

在FXML中为您的Tab分配一个fx:id 使用fx:id绑定控制器中的Tab实例。 现在,您有了实例,可以使用setContent()随时添加内容。

在FXML中

... <Tab fx:id="myTab"> ...

在控制器中:

class Mycontroller { ... @FXML private Tab myTab ... //somewhere in the controller tab.setContent(someNode); ... }

Ofcourse it is possible. Just follow the steps :

Assign an fx:id to your Tab in the FXML Use the fx:id to bind the Tab instance in the controller. Now, you have the instance, you can add contents to it whenever you want, using setContent().

In FXML

... <Tab fx:id="myTab"> ...

In controller :

class Mycontroller { ... @FXML private Tab myTab ... //somewhere in the controller tab.setContent(someNode); ... }

更多推荐

TAB,选项,电脑培训,计算机培训,IT培训"/> <meta name="description" cont

本文发布于:2023-08-07 05:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1461606.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选项卡   文件   内容   动态   fxml

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!