ComponentEvent from a Generic Component

I have the following Class:

public class MyForm <T> extends FormLayout

I am trying to us use the Event Bus from this class.

I have this event class:

public class MyFormEvent <T> extends ComponentEvent<MyForm<T>> {

    private final T data;

    public MyFormEvent (MyForm<T> source, T data) {
        super(source, false); = data;

    public T getData() {
        return data;

I am trying to add a listener in MyForm like such:

    public void addListener(ComponentEventListener<MyFormEvent<T>> listener) {
        return addListener(MyFormEvent.class, listener);

The error i get from this addListener method is

Class<T>                       Class<MyFormEvent>
ComponentEventListener<T>      ComponentEventListener<MyFormEvent<T>>

reason: Incompatible equality constraint: MyFormEvent<T> and MyFormEvent

The addListener method has the following signature

protected <T extends ComponentEvent<?>> Registration addListener(Class<T> eventType, ComponentEventListener<T> listener)

If MyForm wasn’t generic, it works. But I need an event that is generic. Is this possible?

Sadly I’m not very versed with generics. The eventType parameter of addListener is a class object.
It needs to be the same class that is used to set the Type of the ComponentEventListener which is MyFormEvent

With generics you need to cast it: network/network/src/main/java/com/vaadin/componentfactory/ at master · vaadin-component-factory/network · GitHub

This worked, thanks :heart: