设有一个事件:
interface XXXListener {
void event1Happens(String param);
void event2Happens(String param);
}
可以做一个对应的类:
class XXXDispatcher extends Vector implements XXXListener {
public void event1Happens(String param) {
for (XXXListener listener: this) {
listener.event1Happens(param);
}
}
public void event2Happens(String param) {
for (XXXListener listener: this) {
listener.event2Happens(param);
}
}
}
implements XXXListener不是必须的,只是现在大多数IDE都支...[ 查看全文 ]