0

As I am working in NetBeans all components have been auto generated and initialised. the JButton array has been declared as JButton [][] btnArr in the class;

private void createButtons() {
    btnArr = new JButton[10][10];

    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++)
        {
            btnArr[i][j] = new JButton();
            pnlButtons.add(btnArr[i][j]); //Error on this line
            btnArr[i][j].setVisible(true);
            btnArr[i][j].setBounds(i * 30, j * 30, 30, 30);
            btnArr[i][j].setActionCommand("" + i + j);
        }
}

0 Answers0