Java - Add custom event Listener to a eventSet in beanInfo with Netbeans
i have a custom bean and a custom eventListener, i need to show my event Listener in the events tab of my bean.
I think the solution is to add my event Listener to a beaninfo(i create it with netbeans, so it is auto-generated). The开发者_如何学Cre is a "wizard-way" to do this, or i have to hand-write my beaninfo?
Thanks.
The solution is to have all methods for listener management, so Netbeans can recognize it and put it inside beaninfo.
For example, if you have a custom listener called ActionDataListener, you have to add this methods:
public void addActionDataListener(ActionDataListener listener) {
actionDataListeners.add(listener);
}
public void removeActionDataListener(ActionDataListener listener) {
actionDataListeners.remove(listener);
}
public ActionDataListener[] getActionDataListeners() {
return actionDataListeners.toArray(new ActionDataListener[0]);
}
精彩评论