在 for 循环中,我想
- 初始化 JButtons [] bts 。
 - 将按钮添加到面板pan3。
 - 为每个 JButton添加一个ActionListener 。
 
这是我到目前为止所得到的:
for(int i = 0 ;i < bts1.length ; i++){
        bts1[i] = new JButton(""+i);
        pan3.add(bts1[i]);
        //The NullPointerException happens after this line . 
        bts[i].addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent ae){
                int j = 0 ;
                screen.setText(screen.getText()+bts[j].getText());
                j++;
            }
        });
    }
我的问题是如何解决 NullPointerException ? 注意 j 我添加它是因为当我尝试使用 i 时,会发生编译器错误,