gpt4 book ai didi

javafx异常: Controller value already specified

转载 作者:行者123 更新时间:2023-12-04 14:09:30 29 4
gpt4 key购买 nike

我正在通过将一些参数传递给此窗口的特定内部方法来调用一种加载窗口的方法,但是我遇到了以下异常:

GRAVE: null
javafx.fxml.LoadException: Controller value already specified.
unknown path:12

这是我的方法
public void openDef(String sys, String comp, String code) throws Exception {
Stage defStage = new Stage();
FXMLLoader loader = new FXMLLoader();
DefTableController cont = new DefTableController();//calling class controller
loader.setController(cont);
Parent frame = loader.load(getClass().getResource("defTable.fxml").openStream());
cont.getSysChoice(sys, comp, code);//call the method by passing parameters
Scene sceneDef = new Scene(frame);

defStage.setTitle("Défaillance du " + comp);
defStage.setScene(sceneDef);
defStage.show();
}

我不明白为什么它认为 Controller 已经设置好了?以及如何解决?
谢谢你

最佳答案

从FXML文件中删除fx:controller属性。该属性是对FXMLLoader创建新 Controller 的指令:由于您已经通过调用setController设置了一个 Controller ,因此这是矛盾的。

JavaFX Error: Controller value already specified

这个家伙回答了^给他的 Prop !

关于javafx异常: Controller value already specified,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41447390/

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