if(e.getSource()==b1)\\按b1这里为什么进不去
错了.对象相等应该用 equals(); 
if(e.getSource().equals(b1))

解决方案 »

  1.   

    不行啊,这个点击事件,我以前都是if(e.getSource()==b1)这样处理可以的,今天不知道怎么回事?
      

  2.   

    if(e.getSource()==b1)\\按b1这里为什么进不去
    ----------------
    if(e.getSource().getClass()==b1.getClass())
      

  3.   

    见鬼了
    add(b1);b1.addActionListener(this);
    -----
    这两句换一下顺序
    b1.addActionListener(this);add(b1);
      

  4.   

    Button b1 = new Button("connect");把前面的Button去掉
      

  5.   

    看出来了。Button b1 = new Button("connect");
    错了。应该为 b1 = new Button("connect");