1

我想fxml在向其中添加数据后更新我的数据。单击数据中的添加按钮时,priceaddonn.fxml应将数据传输到Sys1.fxml并且应根据priceAddOnn.fxml输入更新表

PriceAddOnController.java

 @FXML
 public void handleAddOnButtonAction(ActionEvent a) {
   try {           
            Stage  stage = new Stage();
            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Sys1.fxml"));
            Parent root44 = (Parent) fxmlLoader.load();   
            Sys1Controller controller=fxmlLoader.<Sys1Controller>getController();             
            stage.setScene(new Scene(root44));               
            //stage.show();
            System.out.println("handleAddOnButtonAction get over extr a var is "+controller.nm);
            System.out.println("call function");
            controller.priceadd();              
        } catch (IOException ex) {
        Logger.getLogger(Sys1Controller.class.getName()).log(Level.SEVERE, null, ex);
    }        
}

Sys1Controller.java

public void priceadd() {       
    try {
            Stage stage = new Stage();
            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("PriceAddonn.fxml"));
            Parent root44 = (Parent) fxmlLoader.load();   
            PriceAddonnController controller=fxmlLoader.<PriceAddonnController>getController();             
            stage.setScene(new Scene(root44));               
            controller.getData();
            data.add(new Person1(controller.charge_nm,controller.chrgeval,controller.var,"Tax"));                       
        System.out.println(" charge nm is "+controller.chrgenm);
    } catch (IOException ex) {
        Logger.getLogger(Sys1Controller.class.getName()).log(Level.SEVERE, null, ex);
    }
}
4

0 回答 0