Doubt about events

Is there any way to trigger events per component?
I have one Component that extends FlexLayout inside this componet I have more 2 or 3 components (with one with an form and fields)

Can I create one way that when I focus or blur some fields I execute one method in my parent component?

I trying to use the ComponentUtil.addListener(this, MyEvent.class, event ->{})

but How can I refer in my subcomponents the parent component to use in
ComponentUtil.fireEvent(?

tks

Simplest would be to use ComponentUtil.fireEvent(UI.getCurrent(), …) The UI is going to find your parent

If only Vaadin events would support “bubling”… I don’t know exactly what you are building and how coupled your components inside that FlexLayout are, but if it is a “composition” or server side “custom component”, I’d jus make the main component listen to all Focusable’s. Something like this:

public FlexFocusExample() {
    add(new TextField());
    add(new Checkbox());

}

@Override
protected void onAttach(AttachEvent attachEvent) {
    super.onAttach(attachEvent);
    getChildren()
            .filter(c -> c instanceof Focusable)
            .map(c -> (Focusable) c)
            .forEach(f -> f.addFocusListener(e -> focusing(f)));
}

private void focusing(Focusable focusable) {
    // TODO do the thing here
    Notification.show("Focused " + focusable.getClass().getSimpleName());
}

Or open a method (public/package private) for components inside your parent component and then you can refer that from some even listener of a child component like this:

findAncestor(FlexFocusExample.class).doSomeMagic();