class MenuPopupWindow extends AbstractWindow {
    private final Panel menuItemPanel;

    /**
     * Creates a new popup window with a relative position to the component supplied.
     * @param parent Component that this popup menu is triggered from
     */
    public MenuPopupWindow(Component parent) {
        setHints(Arrays.asList(Hint.MODAL, Hint.MENU_POPUP, Hint.FIXED_POSITION));
        if (parent != null) {
            TerminalPosition menuPositionGlobal = parent.toGlobal(TerminalPosition.TOP_LEFT_CORNER);
            setPosition(menuPositionGlobal.withRelative(0, 1));
        }
        menuItemPanel = new Panel(new LinearLayout(Direction.VERTICAL));
        setComponent(menuItemPanel);
    }

    /**
     * Adds a new menu item to this popup window. The item will automatically be selected if it's the first one added.
     * @param menuItem Menu item to add to the popup window.
     */
    public void addMenuItem(MenuItem menuItem) {<FILL_FUNCTION_BODY>}
}

        menuItemPanel.addComponent(menuItem);
        menuItem.setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.FILL));
        if (menuItemPanel.getChildCount() == 1) {
            setFocusedInteractable(menuItem);
        }
        invalidate();
    
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void addWindowListener(com.googlecode.lanterna.gui2.WindowListener) ,public void close() ,public void draw(com.googlecode.lanterna.gui2.TextGUIGraphics) ,public com.googlecode.lanterna.TerminalPosition fromGlobal(com.googlecode.lanterna.TerminalPosition) ,public com.googlecode.lanterna.TerminalPosition fromGlobalToContentRelative(com.googlecode.lanterna.TerminalPosition) ,public com.googlecode.lanterna.TerminalPosition fromGlobalToDecoratedRelative(com.googlecode.lanterna.TerminalPosition) ,public final com.googlecode.lanterna.TerminalSize getDecoratedSize() ,public Set<com.googlecode.lanterna.gui2.Window.Hint> getHints() ,public final com.googlecode.lanterna.TerminalPosition getPosition() ,public com.googlecode.lanterna.gui2.WindowPostRenderer getPostRenderer() ,public com.googlecode.lanterna.TerminalSize getPreferredSize() ,public final com.googlecode.lanterna.TerminalSize getSize() ,public com.googlecode.lanterna.gui2.WindowBasedTextGUI getTextGUI() ,public java.lang.String getTitle() ,public boolean handleInput(com.googlecode.lanterna.input.KeyStroke) ,public boolean isVisible() ,public void removeWindowListener(com.googlecode.lanterna.gui2.WindowListener) ,public void setCloseWindowWithEscape(boolean) ,public void setContentOffset(com.googlecode.lanterna.TerminalPosition) ,public final void setDecoratedSize(com.googlecode.lanterna.TerminalSize) ,public void setFixedSize(com.googlecode.lanterna.TerminalSize) ,public void setHints(Collection<com.googlecode.lanterna.gui2.Window.Hint>) ,public final void setPosition(com.googlecode.lanterna.TerminalPosition) ,public void setSize(com.googlecode.lanterna.TerminalSize) ,public void setTextGUI(com.googlecode.lanterna.gui2.WindowBasedTextGUI) ,public void setTitle(java.lang.String) ,public void setVisible(boolean) ,public void setWindowPostRenderer(com.googlecode.lanterna.gui2.WindowPostRenderer) ,public com.googlecode.lanterna.TerminalPosition toGlobal(com.googlecode.lanterna.TerminalPosition) ,public com.googlecode.lanterna.TerminalPosition toGlobalFromContentRelative(com.googlecode.lanterna.TerminalPosition) ,public com.googlecode.lanterna.TerminalPosition toGlobalFromDecoratedRelative(com.googlecode.lanterna.TerminalPosition) ,public void waitUntilClosed() <variables>private boolean closeWindowWithEscape,private com.googlecode.lanterna.TerminalPosition contentOffset,private Set<com.googlecode.lanterna.gui2.Window.Hint> hints,private com.googlecode.lanterna.TerminalSize lastKnownDecoratedSize,private com.googlecode.lanterna.TerminalPosition lastKnownPosition,private com.googlecode.lanterna.TerminalSize lastKnownSize,private com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI,private java.lang.String title,private boolean visible,private com.googlecode.lanterna.gui2.WindowPostRenderer windowPostRenderer