Share event function between two buttons

Hello, I am somewhat new to CUBA. I would like to know if its possible to share a click response event between 2 buttons…the code below wont work… I’m trying to switch fragments on my screen by clicking buttons. But its very verbose… is there a way to achieve this? Thank you in advance.

// SEEMS LIKE I CANT SUBSCRIBE MORE THAN ONE BUTTON TO A GIVEN FUNCTION....
@Subscribe("btnAttachemtFragment")
@Subscribe("btnPhysicianFragment")
public void sharedFunction(Button.ClickEvent event) {
//Button ID could be the fragment controller name
    this.changeFragment(event.getSource().getId());
}

private void changeFragment(String fragmentControllerName) {
    vboxFragments.removeAll();
    ScreenFragment screenFragment = fragments.create(this, fragmentControllerName);
    vboxFragments.add(screenFragment.getFragment());
}

I think I was able to figure it out… by looping through the hbox that has the buttons in can loop and subscribe a click event… much less verbose… any comment on this code would be appreciated.

@Inject
private Fragments fragments;

@Inject
private VBoxLayout cntFragment;

@Inject
private ButtonsPanel pnlFragmentButtons;


@Subscribe
public void onInit(InitEvent event) {
    this.setupFragmentButtonPanel();
}

private void setupFragmentButtonPanel() {
    for (Component component : pnlFragmentButtons.getComponents()) {
        ((Button) component).addClickListener(clickEvent -> {
            cntFragment.removeAll();
            // 4 CHAR btn_ prefix followed by the UI Controller name of the fragment
            ScreenFragment screenFragment = fragments.create(this, clickEvent.getSource().getId().substring(4));
            System.out.println(clickEvent.getSource().getId().substring(4));
            cntFragment.add(screenFragment.getFragment());
        });
    }
}

You can also get your buttons by name like this:

@Subscribe
public void onInit(InitEvent event) {
    ((Button) getWindow().getComponentNN("myBtn")).addClickListener(clickEvent -> {
        
    });
}