Im trying to load fxml files into gridpane when init the parent controller. Each cell in gridpane will load the .fxml file. But i can't load the fxml file in init method.
There is my code
private GridPane gridDetailCollection;
public void initialize(URL location, ResourceBundle resources) {
ObservableList<String> list = FXCollections.observableArrayList();
list.add("1");
list.add("2");
list.add("3");
combo.setItems(list);
System.out.println("detail collection");
try{
Node nodeItem1 = (Node) FXMLLoader.load(getClass().getResource("/fxml/DetailCollectionItem.fxml"));
Node nodeItem2 = (Node) FXMLLoader.load(getClass().getResource("/fxml/DetailCollectionItem.fxml"));
gridDetailCollection.add(nodeItem1,0,0);
gridDetailCollection.add(nodeItem2,1,0);
}catch(IOException e)
{
System.out.println(e.getMessage());
}
File DetailCollectionItem.fxml removed the "fx:controller"
Can anyone solve this problem? Thanks so much.