Class Option

  • Direct Known Subclasses:
    Menu

    public class Option
    extends java.lang.Object
    Option displayed in a menu. The user will be prompted to type the shortcut to select it.
    • Constructor Summary

      Constructors 
      Constructor Description
      Option​(java.lang.String title, java.lang.String shortcut)
      Creates an option.
      Option​(java.lang.String title, java.lang.String shortcut, Action action)
      Creates an option.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MenuRenderer getRenderer()
      Returns the renderer applied to this option.
      java.lang.String getShortcut()
      Returns the shortcut to select the option.
      java.lang.String getTitle()
      Returns the title of the option.
      void setAction​(Action action)
      Binds an action to the option.
      void setRenderer​(MenuRenderer menuRenderer)
      Overrides the default renderer with a custom one, the menuRenderer will be applied to this and all the sub-menus.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Option

        public Option​(java.lang.String title,
                      java.lang.String shortcut)
        Creates an option.
        Parameters:
        title - The title of the option.
        shortcut - The shortcut that selects it.
      • Option

        public Option​(java.lang.String title,
                      java.lang.String shortcut,
                      Action action)
        Creates an option.
        Parameters:
        title - The title of the option.
        shortcut - The shortcut that selects it.
        action - The action that will be triggered if the option is selected.
    • Method Detail

      • getShortcut

        public java.lang.String getShortcut()
        Returns the shortcut to select the option.
        Returns:
        The shortcut to select the option
      • getTitle

        public java.lang.String getTitle()
        Returns the title of the option.
        Returns:
        The title of the option
      • setAction

        public void setAction​(Action action)
        Binds an action to the option.
        Parameters:
        action - The object who possesses the optionSelected() method that will be triggered if the option is selected.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • setRenderer

        public void setRenderer​(MenuRenderer menuRenderer)
        Overrides the default renderer with a custom one, the menuRenderer will be applied to this and all the sub-menus.
        Parameters:
        menuRenderer - The Renderer that will be applied.
      • getRenderer

        public MenuRenderer getRenderer()
        Returns the renderer applied to this option.
        Returns:
        The renderer applied to this option.