本文介绍了javafx在新选项卡中动态打开新的fxml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建一个Javafx程序,在其中我需要在新选项卡中动态打开一个新的fxml文件.
I am creating a javafx program in which i need to open a new fxml file in new tab dynamically.
我希望当用户单击button
时,将使用new fxml file
打开一个新选项卡.
I want that When user click on button
a new tab is opened with new fxml file
.
我不知道我可以根据需要添加任意数量的标签,但是我想在用户单击button
时才打开dynamically
,然后仅打开一个新标签.
I Had no idea I can add tab as per design as much as i need but i want to do it dynamically
when user click on button
then only a new tab open.
我还看到了查询,但不适用于我.请帮助我.
I had also seen Questing but not working for me.Please help me.
谢谢.
推荐答案
您可以使用以下方式动态添加标签页
You can add tabs dynamically with
myTabPane.getTabs().add(myNewTab);
使用new Tab()
创建新的标签页,加载FXML并调用
Create a new Tab with new Tab()
, load your FXML and call
myNewTab.setContent(loadedFxmlRoot);
这篇关于javafx在新选项卡中动态打开新的fxml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!