lundi 31 octobre 2016

How to mark a checkbox in a 2d array JAVA?

Im trying to mark an checkbox in a 2d ARRAY with this code

 checks [0] [1].setSelected(true);

And this is my 2d checkboxes array:

 // Creando Checkbox
     final int NUM_BOXES = 14; // named constant
JCheckBox[][] checks = new JCheckBox[NUM_BOXES][NUM_BOXES];
for (int i = 0; i < NUM_BOXES; i++) {
    for (int j = 0; j < NUM_BOXES; j++) {
        checks[i][j] = new JCheckBox("");
        this.add(checks[i][j]);
        checks [0] [1].setSelected(true);
    }
}

can someone help me?




Aucun commentaire:

Enregistrer un commentaire