在我的GUI应用程序中,我有两个视图:playlistView.fxml和videoView.fxml。每一个都有自己的控制器。我希望playListView成为videoView布局的一部分,所以我使用:
<fx:include fx:id="idPlayListAnchorPane" source="playListView.fxml" />
要包含该文件。 运行良好,播放列表显示为videoView布局的一部分。
然后,我像这样将 idPlayListAnchorPane FXML变量注入到 VideoViewController 中:
@FXML
private AnchorPane idPlayListAnchorPane;
这也可以实现。例如,我可以使用以下代码从 VideoViewController 中禁用 playListView 中的 idPlayListAnchorPane:
idPlayListAnchorPane.setDisable(true);
为了获得playListViewController,我使用以下代码:
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/designer/views/video/playListView.fxml"));
PlayListViewController playListViewController = new PlayListViewController();
loader.setController(playListViewController);
try {
AnchorPane playListView = (AnchorPane) loader.load();
} catch (IOException e) {
};
然后我可以调用例如:
playListViewController.init();
来自videoViewController。
但是init()方法在playListView ListView中创建了一些测试值(作为一个单独的应用程序进行测试,并且可以正常工作)。然而,这些测试值现在没有显示在ListView中。经过多个小时的简单问题是:为什么呢?