4

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

Damien
  • 1,161
  • 2
  • 19
  • 31
Hayat Bellafkih
  • 587
  • 2
  • 11
  • 28

1 Answers1

9

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);
    ...}
    
Vishrant
  • 15,456
  • 11
  • 71
  • 120
Hayat Bellafkih
  • 587
  • 2
  • 11
  • 28