vaadin 8 custom listener

How can I create one component thats fire one listener something like this:

public class MyClass extends VerticalLayout {
    public MyClass(){
    Button btn = new Button("Teste");
    btn.addClickListener(evt->{ FIRE ONE EVENT});

public class MyClass2 extends VerticalLayout {
    public MyClass2(){
    MyClass myClass = new MyClass();
myClass.addMyListener(evt-> { will execute when user click in btn from MyClass} );



it depends a bit if you want to do it the Vaadin 8 way or not, but take a look at in the Framework
for a pretty good example. As long as you’re extending any Component, you will be also extending AbstractClientConnector, which has the basic functionality for event handling. Look especially at line #318, where the addClickListener method is defined:

and on line #357
you can see how to fire an EventObject.

Hope this helps,