楼上的,我试了,不行,报错如下:
java.lang.NullPointerException

解决方案 »

  1.   

    if(e.getActionCommand()!=" ")字符串不是这么比较的,要用equals,当然跟上面的错误没关系
      

  2.   

    会不会是你的索引错了?或者int index = Integer.parseInt(e.getActionCommand());错了因为你if(e.getActionCommand()!=" ")是比较不出来的,永远都是TRUE。
    应该是if(!e.getActionCommand().equal(" "))
    还有,你的" "应该是""吗?
      

  3.   

    试一下  b[index].setLabel(" ");
      

  4.   

    你可以这样:
    public void actionPerformed(ActionEvent e){
      for(int i=0;i<16;i++){
        if(e.getSource()==b[i])
          b[i].setLabel("");
      }
    }
    不过,这种方法比较笨:)