gpt4 book ai didi

java - 如何在 Pane 中加载 fxml 文件?

转载 作者:搜寻专家 更新时间:2023-10-30 19:57:43 25 4
gpt4 key购买 nike

enter image description here

如果我们有一个 Stage 那么 Scene 包括 2 个 Pane第一个 Pane 包含 Button,第二个 Pane 是空的我们可以在第二个 Pane 中加载其他 fxml 文件吗?

fxml1: VBox
|_Pane1-->Button
|_Pane2
///////////////
fxml2: Pane--> Welcome to fxml 2
"when we click the button load the fxml2 inside Pane2 of fxml1"

然后点击之后

enter image description here


====我在尝试后终于找到了这个作品!====谢谢你们

@FXML Pane secPane;
public void loadFxml (ActionEvent event) {
Pane newLoadedPane = FXMLLoader.load(getClass().getResource("/application/fxml2.fxml"));
secPane.getChildren().add(newLoadedPane);
}

最佳答案

经过尝试,我终于找到了这个方法!

@FXML Pane secPane;
public void loadFxml (ActionEvent event) {
Pane newLoadedPane = FXMLLoader.load(getClass().getResource("/application/fxml2.fxml"));
secPane.getChildren().add(newLoadedPane);
}

关于java - 如何在 Pane 中加载 fxml 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33748127/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com