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
发布评论