【发布时间】:2013-12-28 23:46:14
【问题描述】:
我已经调整了我的控制器构造函数和 fxml,以便控制器的所有 fxml 设置都在 fxml 中,除了 FXML 构造和 fxml 加载。这是我的控制器:
public class MainOverviewTab extends Tab {
@FXML private AnchorPane content;
public MainOverviewTab() {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("main_overview_tab.fxml"));
// fxmlLoader.setRoot(content);
// fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (Exception e) {
e.printStackTrace();
}
}
还有我的 fxml 文件:
<AnchorPane id="AnchorPane"
fx:id="content"
fx:controller="dominion.application.controller.MainOverviewTab"
...other settings >
<children>
....
</children>
</AnchorPane>
当调用 fxmlLoader.load() 并返回 FXMLLoader fxmlLoader = new FXMLLoader(...) 然后再次调用 fxmlLoader.load() 时会发生堆栈溢出...为什么会发生这种情况,我该怎么办保持我的控制器构造函数相同并加载相同的 fxml?或者这不可能?
【问题讨论】:
-
this answer 可能会有所帮助