Is it possible to create an array of JavaFX objects that can be accessed.
Currently I have:
@FXML
private CheckBox pc1,pc2,pc4,pc8,pc16,pc32,pc64,pc128,pc256,pc512,pc1024,pc2048;
private final CheckBox[] pcController = {pc1,pc2,pc4,pc8,pc16,pc32,pc64,pc128,
pc256,pc512,pc1024,pc2048};
I am trying to access these objects and flip the check box based on the value in a different array as such:
boolean[] bits = getBits();
for(int i =0; i<pcController.length;i++){
pcController[i].setSelected(bits[i]);
}
I get the error:
Cannot invoke "javafx.scene.control.CheckBox.setSelected(boolean)" because "this.pcController[i]" is null ...
Edit: So I can get the system to semi-work if I instantiate the array inside a method.