i want to create button by loop as
- 1 2 3
- 4 5 6
- 7 8 9
but button have array2D when i write code is
private JButton cells[][];
// Constructor
public SliderGameFrame() {
    JPanel panel = new JPanel();
    this.add(panel);
    for (int i = 1; i <= cells.length; i++) {
        for (int j = 1; j <= cells.length; j++) {
            cells[i][j] = new JButton(" " + i);
            panel.add(cells[i][j]);
        }
    }
}
it's doesn't work and error massage is java.lang.NullPointerException
 
     
    