Class Menu

  • All Implemented Interfaces:
    com.googlecode.lanterna.gui2.Component, com.googlecode.lanterna.gui2.Interactable, com.googlecode.lanterna.gui2.TextGUIElement

    public class Menu
    extends com.googlecode.lanterna.gui2.Button
    Represents a lanterna menu.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.googlecode.lanterna.gui2.Button

        com.googlecode.lanterna.gui2.Button.BorderedButtonRenderer, com.googlecode.lanterna.gui2.Button.ButtonRenderer, com.googlecode.lanterna.gui2.Button.DefaultButtonRenderer, com.googlecode.lanterna.gui2.Button.FlatButtonRenderer, com.googlecode.lanterna.gui2.Button.Listener
      • Nested classes/interfaces inherited from interface com.googlecode.lanterna.gui2.Interactable

        com.googlecode.lanterna.gui2.Interactable.FocusChangeDirection, com.googlecode.lanterna.gui2.Interactable.Result
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected MenuListDialogBuilder builder
      for generating the menu.
      protected com.googlecode.lanterna.gui2.WindowBasedTextGUI context
      the context.
    • Constructor Summary

      Constructors 
      Constructor Description
      Menu​(String label, com.googlecode.lanterna.gui2.WindowBasedTextGUI context)
      Initializes the menu.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addMenuItem​(MenuItem item)
      Adds the menu item.
      void addMenuItem​(String label, Runnable action)
      Adds the menu item (name and action).
      protected com.googlecode.lanterna.gui2.Button.Listener newListener()
      Returns the button listener, which pops up the action list dialog displaying the menu.
      • Methods inherited from class com.googlecode.lanterna.gui2.Button

        addListener, createDefaultRenderer, getCursorLocation, getLabel, handleKeyStroke, removeListener, setLabel, toString, triggerActions
      • Methods inherited from class com.googlecode.lanterna.gui2.AbstractInteractableComponent

        afterEnterFocus, afterLeaveFocus, getInputFilter, getRenderer, handleInput, isEnabled, isFocusable, isFocused, onEnterFocus, onLeaveFocus, setEnabled, setInputFilter, takeFocus
      • Methods inherited from class com.googlecode.lanterna.gui2.AbstractComponent

        addTo, calculatePreferredSize, draw, getBasePane, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isInvalid, onAdded, onAfterDrawing, onBeforeDrawing, onRemoved, runOnGUIThreadIfExistsOtherwiseRunDirect, self, setLayoutData, setPosition, setPreferredSize, setRenderer, setSize, setTheme, toBasePane, toGlobal, withBorder
      • Methods inherited from interface com.googlecode.lanterna.gui2.Component

        addTo, getBasePane, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, onAdded, onRemoved, setLayoutData, setPosition, setPreferredSize, setSize, setTheme, toBasePane, toGlobal, withBorder
      • Methods inherited from interface com.googlecode.lanterna.gui2.TextGUIElement

        draw, isInvalid
    • Field Detail

      • context

        protected com.googlecode.lanterna.gui2.WindowBasedTextGUI context
        the context.
    • Constructor Detail

      • Menu

        public Menu​(String label,
                    com.googlecode.lanterna.gui2.WindowBasedTextGUI context)
        Initializes the menu.
        Parameters:
        label - the name of the menu
    • Method Detail

      • newListener

        protected com.googlecode.lanterna.gui2.Button.Listener newListener()
        Returns the button listener, which pops up the action list dialog displaying the menu.
        Returns:
        the listener
      • addMenuItem

        public void addMenuItem​(String label,
                                Runnable action)
        Adds the menu item (name and action).
        Parameters:
        label - Label of the menu item
        action - Action to perform if the user selects this item
      • addMenuItem

        public void addMenuItem​(MenuItem item)
        Adds the menu item.
        Parameters:
        item - the menu item