[英]javafx open a new fxml file in new tab dynamically
I am creating a javafx program in which i need to open a new fxml file in new tab dynamically. 我正在创建一个javafx程序,在其中我需要在新选项卡中动态打开一个新的fxml文件。
I want that When user click on button
a new tab is opened with new fxml file
. 我希望当用户单击button
将使用new fxml file
打开一个新选项卡。
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. 我不知道我可以根据需要按设计添加标签,但是当用户单击button
然后仅打开一个新标签时,我想dynamically
添加标签。
I had also seen Questing but not working for me. 我也看过《 Questing》,但没有为我工作。 Please help me. 请帮我。
Thank you. 谢谢。
You can add tabs dynamically with 您可以使用以下方式动态添加标签
myTabPane.getTabs().add(myNewTab);
Create a new Tab with new Tab()
, load your FXML and call 使用new Tab()
创建一个新的Tab,加载您的FXML并调用
myNewTab.setContent(loadedFxmlRoot);
You can add tabs using this code, you need to confirm if your tabPane has this tab or no, else your program invokes SizeOfBounds exception. 您可以使用此代码添加选项卡,您需要确认tabPane是否具有此选项卡,否则程序将调用SizeOfBounds异常。
if (!MessagePane.getTabs().contains(AllMessageTab)) {
MessagePane.getTabs().add(AllMessageTab);
}
SingleSelectionModel<Tab> selectionModel = MessagePane.getSelectionModel();
selectionModel.select(AllMessageTab);
AllMessageTab.setContent(_YourContentNodeHere);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.