class Menu extends MenuItem {
    private final List<MenuItem> subItems;

    /**
     * Creates a menu with the specified label
     * @param label Label to use for the menu item that will trigger this menu to pop up
     */
    public Menu(String label) {
        super(label);
        this.subItems = new ArrayList<>();
    }

    /**
     * Adds a new menu item to this menu, this can be either a regular {@link MenuItem} or another {@link Menu}
     * @param menuItem The item to add to this menu
     * @return Itself
     */
    public Menu add(MenuItem menuItem) {
        synchronized (subItems) {
            subItems.add(menuItem);
        }
        return this;
    }

    @Override
    protected boolean onActivated() {<FILL_FUNCTION_BODY>}
}

        boolean result = true;
        if (subItems.isEmpty()) {
            return result;
        }
        final MenuPopupWindow popupMenu = new MenuPopupWindow(this);
        final AtomicBoolean popupCancelled = new AtomicBoolean(false);
        for (MenuItem menuItem : subItems) {
            popupMenu.addMenuItem(menuItem);
        }
        if (getParent() instanceof MenuBar) {
            final MenuBar menuBar = (MenuBar) getParent();
            popupMenu.addWindowListener(new WindowListenerAdapter() {
                @Override
                public void onUnhandledInput(Window basePane, KeyStroke keyStroke, AtomicBoolean hasBeenHandled) {
                    if (keyStroke.getKeyType() == KeyType.ARROW_LEFT) {
                        int thisMenuIndex = menuBar.getChildrenList().indexOf(Menu.this);
                        if (thisMenuIndex > 0) {
                            popupMenu.close();
                            Menu nextSelectedMenu = menuBar.getMenu(thisMenuIndex - 1);
                            nextSelectedMenu.takeFocus();
                            nextSelectedMenu.onActivated();
                        }
                    } else if (keyStroke.getKeyType() == KeyType.ARROW_RIGHT) {
                        int thisMenuIndex = menuBar.getChildrenList().indexOf(Menu.this);
                        if (thisMenuIndex >= 0 && thisMenuIndex < menuBar.getMenuCount() - 1) {
                            popupMenu.close();
                            Menu nextSelectedMenu = menuBar.getMenu(thisMenuIndex + 1);
                            nextSelectedMenu.takeFocus();
                            nextSelectedMenu.onActivated();
                        }
                    }
                }
            });
        }
        popupMenu.addWindowListener(new WindowListenerAdapter() {
            @Override
            public void onUnhandledInput(Window basePane, KeyStroke keyStroke, AtomicBoolean hasBeenHandled) {
                if (keyStroke.getKeyType() == KeyType.ESCAPE) {
                    popupCancelled.set(true);
                    popupMenu.close();
                }
            }
        });
        ((WindowBasedTextGUI) getTextGUI()).addWindowAndWait(popupMenu);
        result = !popupCancelled.get();
        
        return result;
    
<methods>public void <init>(java.lang.String) ,public void <init>(java.lang.String, java.lang.Runnable) ,public java.lang.String getLabel() <variables>private final non-sealed java.lang.Runnable action,private java.lang.String label