0
My system consists of a main screen, which has a scroll-pane that I’m populating with a list of other FXML scenes, code from which I took an example on the internet, follows the code:
@FXML
private Label label;
@FXML
private VBox pnl_scroll;
@FXML
private void handleButtonAction(MouseEvent event) {
refreshNodes();
}
@Override
public void initialize(URL url, ResourceBundle rb) {
refreshNodes();
}
private void refreshNodes() {
pnl_scroll.getChildren().clear();
Node[] nodes = new Node[15];
for (int i = 0; i < 10; i++) {
try {
nodes[i] = (Node) FXMLLoader.load(getClass().getResource("Item.fxml"));
pnl_scroll.getChildren().add(nodes[i]);
} catch (IOException ex) {
Logger.getLogger(HomeController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
The problem is, I need to set the data for each scroll-pane.fxml item before adding it, how can I do this?
Thank you!
At first, I’m getting access to my controller’s methods. I made a test method in the item’s controller, which writes on the console, but gives Nullpointerexception at the time of execution.
– João Vitor Aguiar
I’m already able to access the methods of the other controller, but I can’t set the values of the Labels, even creating getters and setters.
– João Vitor Aguiar