将JLabel的2D数组添加到面板时出现NullPointerException

时间:2016-05-08 15:51:39

标签: java arrays nullpointerexception

当我尝试将JLabel数组添加到我的面板时,我得到一个NullPointer异常。

错误发生在内循环的最后一行

Panel panneauScore;
Panel panneaujouonsAuGolf;
Label [][] arrayscore = new Label [4][9];

for (int c = 0; c<arrayscore.length; c++){
        for (int p = 0; p<arrayscore[c].length; p++){
            score1 = Choisirrandom();
            nombre[c][p] = score1; 
            arrayscore[c][p]= new Label(String.valueOf(nombre[c][p]));
            panneauScore.add(arrayscore[c][p]);
        }
    }

0 个答案:

没有答案