mercredi 6 novembre 2019

How to add checkboxes to a GridPane in JavaFX?

I'm a beginner in JavaFX and trying to add 25 checkboxes so that they're arranged in five rows of 5. I created a GridPane in scenebuilder and wrote the below code to add the checkboxes to the GridPane. However, I'm getting an InvocationTargetException?

public class GameController {
    @FXML 
    private GridPane boxGridPane;

    @FXML
    public void initialize() {
        for (int i = 0; i < 25; i++) {
            CheckBox c = new CheckBox();
            boxGridPane.add(c, 0, 0);
        }
    }
}



Aucun commentaire:

Enregistrer un commentaire