单击超链接时,我试图打开一个新窗口。由于某种原因,它只能工作一次,然后我再也无法使其工作了。每次运行它时,都会出现javafx.fxml.LoadException: Root value already specified.
错误。问题是我没有在任何地方设置根值。
我尝试了loader.setRoot(null)
,但没有做任何事情。我从来没有在我的fxml或常规方法中设置根目录,所以我不确定它从哪里得到。
这是加载新窗口的方法
@FXML
private void initialize(){
messageSupports.setOnMouseClicked(e -> {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/MessagingSupportLayout.fxml"));
// Parent root = (Parent) loader.load();
Stage secondaryStage = new Stage();
loader.setController(new MessagingSupport(mainController));
mainController.getContentPane().getChildren().add(loader.load());
secondaryStage.setTitle("Support");
secondaryStage.setHeight(500);
secondaryStage.setWidth(350);
Scene scene = new Scene(loader.load());
secondaryStage.setScene(scene);
secondaryStage.show();
} catch (IOException ex) {
ex.printStackTrace();
}
});
}
}
这是MessagingSupportLayout.fxml
的fxml。
<BorderPane xmlns="http://javafx.com/javafx"
prefHeight="400.0" prefWidth="600.0">
</BorderPane>
预期结果是将打开一个新窗口。我使用start方法在主类中设置了第一个窗口的标题,高度,宽度。我没有在那里或在fxml中声明根。如果您需要查看,可以张贴。感谢您的帮助!
答案 0 :(得分:0)
弄清楚了。第df_output = pd.DataFrame({"DATE":[2019,2020],"OUTPUT":[114.159375,120.530807]})
行设置了根。删除该行即可解决问题。