我正在从主控制器类创建一个新的模态对话框。在显示之前,如何在对话框中设置一些文本字段值?
URL url = getClass().getResource("SeedNodeForm.fxml");
Stage stage = new Stage();
stage.setTitle("Seed Node Information");
stage.initModality(Modality.WINDOW_MODAL);
stage.initOwner(((Node) event.getSource()).getScene().getWindow());
stage.initStyle(StageStyle.UTILITY);
Parent root = FXMLLoader.load(url);
stage.setScene(new Scene(root));
stage.centerOnScreen();
textfield1.setValue("富"!);
textfield2.setValue(" foo2的&#34);
stage.showAndWait();
答案 0 :(得分:0)
谢谢你Uluk Biy - 你的链接让我得到了答案:
// get the controller from the loader
SeedNodeFormController c = (SeedNodeFormController) fxmlLoader.getController();
// call setter in controller routine to set needed values
c.setSeedNode(value);