class MenuBar extends AbstractComponent<MenuBar> implements Container {
    private static final int EXTRA_PADDING = 0;
    private final List<Menu> menus;

    /**
     * Creates a new menu bar
     */
    public MenuBar() {
        this.menus = new CopyOnWriteArrayList<>();
    }

    /**
     * Adds a new drop-down menu to the menu bar, at the end
     * @param menu Menu to add to the menu bar
     * @return Itself
     */
    public MenuBar add(Menu menu) {
        menus.add(menu);
        menu.onAdded(this);
        return this;
    }

    @Override
    public int getChildCount() {
        return getMenuCount();
    }

    @Override
    public List<Component> getChildrenList() {
        return new ArrayList<>(menus);
    }

    @Override
    public Collection<Component> getChildren() {
        return getChildrenList();
    }

    @Override
    public boolean containsComponent(Component component) {
        return menus.contains(component);
    }

    @Override
    public synchronized boolean removeComponent(Component component) {
        boolean hadMenu = menus.remove(component);
        if (hadMenu) {
            component.onRemoved(this);
        }
        return hadMenu;
    }

    @Override
    public synchronized Interactable nextFocus(Interactable fromThis) {
        if (menus.isEmpty()) {
            return null;
        }
        else if (fromThis == null) {
            return menus.get(0);
        }
        else if (!menus.contains(fromThis) || menus.indexOf(fromThis) == menus.size() - 1) {
            return null;
        }
        else {
            return menus.get(menus.indexOf(fromThis) + 1);
        }
    }

    @Override
    public Interactable previousFocus(Interactable fromThis) {<FILL_FUNCTION_BODY>}

    @Override
    public boolean handleInput(KeyStroke key) {
        return false;
    }

    /**
     * Returns the drop-down menu at the specified index. This method will throw an Array
     * @param index Index of the menu to return
     * @return The drop-down menu at the specified index
     * @throws IndexOutOfBoundsException if the index is out of range
     */
    public Menu getMenu(int index) {
        return menus.get(index);
    }

    /**
     * Returns the number of menus this menu bar currently has
     * @return The number of menus this menu bar currently has
     */
    public int getMenuCount() {
        return menus.size();
    }

    @Override
    protected ComponentRenderer<MenuBar> createDefaultRenderer() {
        return new DefaultMenuBarRenderer();
    }

    @Override
    public synchronized void updateLookupMap(InteractableLookupMap interactableLookupMap) {
        for (Menu menu: menus) {
            interactableLookupMap.add(menu);
        }
    }

    @Override
    public TerminalPosition toBasePane(TerminalPosition position) {
        // Assume the menu is always at the top of the content panel
        return position;
    }
    
    public boolean isEmptyMenuBar() {
        return false;
    }

    /**
     * The default implementation for rendering a {@link MenuBar}
     */
    public class DefaultMenuBarRenderer implements ComponentRenderer<MenuBar> {
        @Override
        public TerminalSize getPreferredSize(MenuBar menuBar) {
            int maxHeight = 1;
            int totalWidth = EXTRA_PADDING;
            for (int i = 0; i < menuBar.getMenuCount(); i++) {
                Menu menu = menuBar.getMenu(i);
                TerminalSize preferredSize = menu.getPreferredSize();
                maxHeight = Math.max(maxHeight, preferredSize.getRows());
                totalWidth += preferredSize.getColumns();
            }
            totalWidth += EXTRA_PADDING;
            return new TerminalSize(totalWidth, maxHeight);
        }

        @Override
        public void drawComponent(TextGUIGraphics graphics, MenuBar menuBar) {
            // Reset the area
            graphics.applyThemeStyle(getThemeDefinition().getNormal());
            graphics.fill(' ');

            int leftPosition = EXTRA_PADDING;
            TerminalSize size = graphics.getSize();
            int remainingSpace = size.getColumns() - EXTRA_PADDING;
            for (int i = 0; i < menuBar.getMenuCount() && remainingSpace > 0; i++) {
                Menu menu = menuBar.getMenu(i);
                TerminalSize preferredSize = menu.getPreferredSize();
                menu.setPosition(menu.getPosition()
                        .withColumn(leftPosition)
                        .withRow(0));
                int finalWidth = Math.min(preferredSize.getColumns(), remainingSpace);
                menu.setSize(menu.getSize()
                                .withColumns(finalWidth)
                                .withRows(size.getRows()));
                remainingSpace -= finalWidth + EXTRA_PADDING;
                leftPosition += finalWidth + EXTRA_PADDING;
                TextGUIGraphics componentGraphics = graphics.newTextGraphics(menu.getPosition(), menu.getSize());
                menu.draw(componentGraphics);
            }
        }
    }
}

        if (menus.isEmpty()) {
            return null;
        }
        else if (fromThis == null) {
            return menus.get(menus.size() - 1);
        }
        else if (!menus.contains(fromThis) || menus.indexOf(fromThis) == 0) {
            return null;
        }
        else {
            return menus.get(menus.indexOf(fromThis) - 1);
        }
    
<methods>public void <init>() ,public synchronized com.googlecode.lanterna.gui2.menu.MenuBar addTo(com.googlecode.lanterna.gui2.Panel) ,public final synchronized void draw(com.googlecode.lanterna.gui2.TextGUIGraphics) ,public com.googlecode.lanterna.gui2.BasePane getBasePane() ,public com.googlecode.lanterna.TerminalPosition getGlobalPosition() ,public com.googlecode.lanterna.gui2.LayoutData getLayoutData() ,public com.googlecode.lanterna.gui2.Container getParent() ,public com.googlecode.lanterna.TerminalPosition getPosition() ,public final com.googlecode.lanterna.TerminalSize getPreferredSize() ,public synchronized ComponentRenderer<com.googlecode.lanterna.gui2.menu.MenuBar> getRenderer() ,public com.googlecode.lanterna.TerminalSize getSize() ,public com.googlecode.lanterna.gui2.TextGUI getTextGUI() ,public synchronized com.googlecode.lanterna.graphics.Theme getTheme() ,public com.googlecode.lanterna.graphics.ThemeDefinition getThemeDefinition() ,public boolean hasParent(com.googlecode.lanterna.gui2.Container) ,public void invalidate() ,public boolean isInside(com.googlecode.lanterna.gui2.Container) ,public boolean isInvalid() ,public boolean isVisible() ,public synchronized void onAdded(com.googlecode.lanterna.gui2.Container) ,public synchronized void onRemoved(com.googlecode.lanterna.gui2.Container) ,public synchronized com.googlecode.lanterna.gui2.menu.MenuBar setLayoutData(com.googlecode.lanterna.gui2.LayoutData) ,public synchronized com.googlecode.lanterna.gui2.menu.MenuBar setPosition(com.googlecode.lanterna.TerminalPosition) ,public final synchronized com.googlecode.lanterna.gui2.menu.MenuBar setPreferredSize(com.googlecode.lanterna.TerminalSize) ,public com.googlecode.lanterna.gui2.menu.MenuBar setRenderer(ComponentRenderer<com.googlecode.lanterna.gui2.menu.MenuBar>) ,public synchronized com.googlecode.lanterna.gui2.menu.MenuBar setSize(com.googlecode.lanterna.TerminalSize) ,public synchronized com.googlecode.lanterna.gui2.Component setTheme(com.googlecode.lanterna.graphics.Theme) ,public com.googlecode.lanterna.gui2.menu.MenuBar setVisible(boolean) ,public com.googlecode.lanterna.TerminalPosition toBasePane(com.googlecode.lanterna.TerminalPosition) ,public com.googlecode.lanterna.TerminalPosition toGlobal(com.googlecode.lanterna.TerminalPosition) ,public synchronized com.googlecode.lanterna.gui2.Border withBorder(com.googlecode.lanterna.gui2.Border) <variables>private ComponentRenderer<com.googlecode.lanterna.gui2.menu.MenuBar> defaultRenderer,private com.googlecode.lanterna.TerminalSize explicitPreferredSize,private boolean invalid,private com.googlecode.lanterna.gui2.LayoutData layoutData,private ComponentRenderer<com.googlecode.lanterna.gui2.menu.MenuBar> overrideRenderer,private com.googlecode.lanterna.gui2.Container parent,private com.googlecode.lanterna.TerminalPosition position,private com.googlecode.lanterna.TerminalSize size,private com.googlecode.lanterna.graphics.Theme themeOverride,private ComponentRenderer<com.googlecode.lanterna.gui2.menu.MenuBar> themeRenderer,private com.googlecode.lanterna.graphics.Theme themeRenderersTheme,private boolean visible