如何在JavaFX中刷新阶段

时间:2015-07-01 10:41:38

标签: javafx javafx-8 fxml scenebuilder fxmlloader

我希望在添加数据后更新我的fxml。点击priceaddonn.fxml数据中的添加按钮时,应将Sys1.fxml数据传输到priceAddOnn.fxml,并按{{1}更新表格输入

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);
    }
}

0 个答案:

没有答案