Package commandLineMenus
Class Option
- java.lang.Object
-
- commandLineMenus.Option
-
- Direct Known Subclasses:
Menu
public class Option extends java.lang.ObjectOption displayed in a menu. The user will be prompted to type the shortcut to select it.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classOption.ConcurrentModificationExceptionThrown if you try to modify the menus or options once a menu has been launched.classOption.NoActionDefinedExceptionThrown if no action is defined for the current option.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MenuRenderergetRenderer()Returns the renderer applied to this option.java.lang.StringgetShortcut()Returns the shortcut to select the option.java.lang.StringgetTitle()Returns the title of the option.voidsetAction(Action action)Binds an action to the option.voidsetRenderer(MenuRenderer menuRenderer)Overrides the default renderer with a custom one, the menuRenderer will be applied to this and all the sub-menus.java.lang.StringtoString()
-
-
-
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:
toStringin classjava.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.
-
-