请教动作监听问题 通过线层,用一个boolean状态对b2监听. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在b1的事件响应代码中获取b2的动作监听器(listener),比如使用b2的getActionListeners()方法;再调用b2的动作监听器的actionPerformed(ActionEvent e)方法实现对b2的点击。不知此方法是否满足你的要求? 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){ ....... }} 如何判断socket传输文件的类型? 自动重画 问一个关于对象创建的问题 使用apt时需在classpath里设置tools.jar,怎么设置? 请教基本语法this.class.getClassLoader()怎么理解? 为什么struts里面得不到输入流?急 www.netyi.net重新改版,欢迎所有的开发者到这里分享您的经验,下载您需要的资料。 这样的Import有区别吗 我发现了Jcreator的一个大bug,用jcreator的都近来看看吧 送分了,大家快来。 【菜菜的问】java操作windows剪贴板的模块是哪个啊? 新手求助: jdk安装配置的问题
再调用b2的动作监听器的actionPerformed(ActionEvent e)方法实现对b2的点击。不知此方法是否满足你的要求?
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){
.......
}
}