set the content of an anchorPane with fxml file

依然范特西╮ 提交于 2019-12-07 08:42:38

问题


I use the accordion control. Depending on the titled pane, I need to load a fxml file into an anchorPane. So I have two parts: one for accordion and another one for anchorPane to display contents depending on click.

@FXML
private StackPane tmpPane;

@FXML
private void itemMembres(MouseEvent event) throws IOException { 
    tmpPane.getChildren().add((Node)FXMLLoader.load(getClass().getResource("/view/test.fxml")));
}

tmpPane is an anchorPane in the view.

thanks


回答1:


I found the solution

  • Create a node by loanding a fxml file

  • Use setAll of AnchorPane

    @FXML
    private AnchorPane tmpPane
    
    @FXML
    private  void itemMembres(MouseEvent event) throws IOException{
    
    Node node;
    node = (Node)FXMLLoader.load(getClass().getResource("/view/MembresTableau.fxml"));
    tmpPane.getChildren().setAll(node);
    ...}
    


来源:https://stackoverflow.com/questions/25515954/set-the-content-of-an-anchorpane-with-fxml-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!