Ciao a tutti.

Quandro provo a compilare il programma a terminale compare:

"run:
Exception in thread "main" java.lang.NullPointerException
at it.science.unitn.esame.PGrid.<init>(PGrid.java:29)
at it.science.unitn.esame.Pannello.<init>(Pannello.ja va:24)
at it.science.unitn.esame.NewMain.startGraphics(NewMa in.java:24)
at it.science.unitn.esame.NewMain.<init>(NewMain.java :17)
at it.science.unitn.esame.NewMain.main(NewMain.java:3 6)
Java Result: 1


La classe incriminata è questa:

codice:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.science.unitn.esame;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class PGrid extends JPanel{
    
    int contatore = 0;
    
    public static Caselle[] ArrayCaselle;
    
    PGrid(){
        this.setLayout(new GridLayout(8,8,5,5));
        
        this.ArrayCaselle = new Caselle[64];
        
        for(int i = 0; i< 8; i++){
            for(int j = 0; j<8; j++){ 
                
                Caselle c = new Caselle();
                this.ArrayCaselle[contatore].add(c);
                contatore++;
            }           
        }
    }
}

Dove Caselle è una classe che estende JPanel.

Sapete dirmi cosa sbaglio? Sono svariate ore che sto provando a modificare il codice, ma non trovo una soluzione.