MenuItem with Childs listener

Hi,

I have implemented a MenuBar that has a MenuItem with Childs. I need a Listener when the rootItem is clicked and the Dropdown with the Childs is visible. And then I need a Listener when the Dropdown is closed by clicking somewhere else.
In this example the menuSelected() of the rootItem is not executed. Is there a way to make this work or to add a listener for the Dropdown?

MenuBar mainMenu = new MenuBar();
MenuItem rootItem = mainMenu.addItem("Root", new Command() {
    @Override
    public void menuSelected(MenuItem selectedItem) {
        System.out.println("This is not working");
    });
}
rootItem.addItem("Child1", new Command() {
    @Override
    public void menuSelected(MenuItem selectedItem) {
        System.out.println("This is working");
        executeMyCloseCommand();
    });
}
rootItem.addItem("Child2", new Command() {
    @Override
    public void menuSelected(MenuItem selectedItem) {
        System.out.println("This is working");
        executeMyCloseCommand();
    });
}