开发者

Java - Add custom event Listener to a eventSet in beanInfo with Netbeans

开发者 https://www.devze.com 2023-01-15 15:30 出处:网络
i have a custom bean and a custom eventListener, i need to show my event Listener in the events tab of my bean.

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]);
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号