我有两个 .fxml 和两个控制器。
首先,会显示访客信息(蓝色),每当单击“添加”按钮时,它将弹出另一个阶段(灰色/白色)以搜索具有 ICnumber 的访客。
我的计划是当我搜索完一位客人(灰色)后,我将单击“添加客人”按钮,舞台(灰色)将关闭,所有值将传递给客人信息(蓝色)。
@FXML //Guest Information (blue stage)
void addGuest(ActionEvent event) throws IOException {
iclb.setText("ok"); //ignore this
Parent root = FXMLLoader.load(getClass().getResource("Guest.fxml"));
Scene scene = new Scene(root);
Stage stage = new Stage();
stage.setScene(scene);
stage.setTitle("Hotel System - Guest Information");
stage.setResizable(false);
stage.show();
}
public void addGuestInfo(String icno) {
iclb.setText(icno); // this is the label for IC Number
}
--
@FXML //Search Guest (grey stage)
void addGuest(ActionEvent event) throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("MenuDraft.fxml"));
Parent root = loader.load();
MenuController menu = loader.getController();
menu.addGuestInfo(ictf.getText());
Stage stage = (Stage) addbt.getScene().getWindow();
stage.close();
}
到目前为止,我设法搜索了一位客人并能够通过单击“添加客人”按钮关闭灰色阶段,但这些值没有传递给客人信息(蓝色阶段)。
我在使用 Javafx 方面非常新……任何人都可以帮我解决这个问题吗?
