Search code examples
javaswtlistenerevent-listenerkeyup

Does event listeners like keyup/down need to be disposed in java?


I created one event listener on my combobox in

 java SWT as: 

cbInstrumentType.addListener(SWT.KeyUp, (event) -> {});

Does listeners like keyup/ keydown/ keyPressed/ selectionListener and others need to be removed or disposed of?

If yes, how?


Solution

  • Listeners do not need to be removed when the control is disposed.

    The control dispose removes all listeners automatically since it deletes the event table that contains the listeners list. See the Widget.releaseWidget method.