通过线层,用一个boolean状态对b2监听.

解决方案 »

  1.   

    在b1的事件响应代码中获取b2的动作监听器(listener),比如使用b2的getActionListeners()方法;
    再调用b2的动作监听器的actionPerformed(ActionEvent e)方法实现对b2的点击。不知此方法是否满足你的要求?
      

  2.   

    Button b1 = new Button();
    Button b2 = new Button();
    b1.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            ActionListener[] listeners = b2.getActionListeners();
            for(int i=0;i<listeners.length;i++){
                listeners.actionPerformed(e);
            }
            .......
        }
    }
    b2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            .......
        }
    }