1

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). There is a "wizard-way" to do this, or i have to hand-write my beaninfo?

Thanks.

blow
  • 12,811
  • 24
  • 75
  • 112

1 Answers1

1

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]);
    }
blow
  • 12,811
  • 24
  • 75
  • 112
  • The getActionDataListeners method is not required, just the add and remove methods. As illustrated, it is important also that the addListener(Listener listener) naming be used. It is possible to use an inner interface like addListener(Parent.Listener listener). But naming like addListener(Listener listener) won't work. – Ted Jul 24 '19 at 22:44