如何在窗格内加载fxml文件? [英] How to load fxml file inside Pane?
本文介绍了如何在窗格内加载fxml文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我们有 Stage
,那么场景
包含2 窗格
s
第1个窗格
包含按钮
和第二个窗格
为空
我们可以在第二个<$ c $中加载其他fxml文件c> Pane ?
If we have a Stage
then Scene
includes 2 Pane
s
the 1st Pane
contains Button
and the 2nd Pane
is empty
could we load other fxml file inside this 2nd Pane
?
fxml1: VBox
|_Pane1-->Button
|_Pane2
///////////////
fxml2: Pane--> Welcome to fxml 2
"when we click the button load the fxml2 inside Pane2 of fxml1"
然后点击
====我终于在尝试后找到了这个作品!====谢谢你们
====I finally found this works after trying !====Thank you guys
@FXML Pane secPane;
public void loadFxml (ActionEvent event) {
Pane newLoadedPane = FXMLLoader.load(getClass().getResource("/application/fxml2.fxml"));
secPane.getChildren().add(newLoadedPane);
}
推荐答案
我终于发现这个有用了尝试!
I finally found this works after trying !
@FXML Pane secPane;
public void loadFxml (ActionEvent event) {
Pane newLoadedPane = FXMLLoader.load(getClass().getResource("/application/fxml2.fxml"));
secPane.getChildren().add(newLoadedPane);
}
这篇关于如何在窗格内加载fxml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文