【发布时间】:2017-05-06 11:45:06
【问题描述】:
我创建了一个动作监听器,它监听 departingStop(组合框对象)是否有任何变化
departingStop.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//Lots of code here
}
});
我还想将此动作侦听器添加到另一个组合框 (finalStop),而不必像这样创建单独的侦听器:
finalStop.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//Lots of code here
}
});
如何做到这一点?谢谢
【问题讨论】:
-
这个动作监听器是匿名的,你需要一个设置为两者的引用
标签: java callback actionlistener anonymous-types