Class OptionDialog

  • All Implemented Interfaces:
    com.googlecode.lanterna.gui2.BasePane, com.googlecode.lanterna.gui2.Composite, com.googlecode.lanterna.gui2.Window

    public class OptionDialog
    extends com.googlecode.lanterna.gui2.dialogs.DialogWindow
    Dialog for displaying a combobox with options.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Nested Class Summary

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

        com.googlecode.lanterna.gui2.AbstractBasePane.ContentHolder
      • Nested classes/interfaces inherited from interface com.googlecode.lanterna.gui2.Window

        com.googlecode.lanterna.gui2.Window.Hint
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected com.googlecode.lanterna.gui2.ComboBox<String> comboBox
      the combobox with the options.
      protected String result
      the chosen option.
      • Fields inherited from class com.googlecode.lanterna.gui2.AbstractBasePane

        contentHolder, interactableLookupMap
    • Constructor Summary

      Constructors 
      Constructor Description
      OptionDialog​(String title, String description, String[] options, String initial)
      Default constructor, takes a title for the dialog and runs code shared for dialogs
      OptionDialog​(String title, String description, String[] options, String initial, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints)
      Default constructor, takes a title for the dialog and runs code shared for dialogs
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void onCancel()  
      protected void onOK()  
      String showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI)  
      static String showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, String[] options, String initial)
      Shortcut for quickly showing a OptionDialog.
      static String showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, String[] options, String initial, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints)
      Shortcut for quickly showing a OptionDialog.
      • Methods inherited from class com.googlecode.lanterna.gui2.AbstractWindow

        addWindowListener, close, draw, fromGlobal, getDecoratedSize, getHints, getPosition, getPostRenderer, getPreferredSize, getSize, getTextGUI, getTitle, handleInput, isVisible, removeWindowListener, setCloseWindowWithEscape, setContentOffset, setDecoratedSize, setHints, setPosition, setSize, setTextGUI, setTitle, setVisible, setWindowPostRenderer, toGlobal, waitUntilClosed
      • Methods inherited from class com.googlecode.lanterna.gui2.AbstractBasePane

        addBasePaneListener, getBasePaneListeners, getComponent, getCursorPosition, getFocusedInteractable, getTheme, invalidate, isInvalid, removeBasePaneListener, setComponent, setEnableDirectionBasedMovements, setFocusedInteractable, setFocusedInteractable, setStrictFocusChange, setTheme
      • Methods inherited from interface com.googlecode.lanterna.gui2.BasePane

        getTheme, setEnableDirectionBasedMovements, setStrictFocusChange, setTheme
      • Methods inherited from interface com.googlecode.lanterna.gui2.Window

        getComponent, getCursorPosition, getFocusedInteractable, invalidate, isInvalid, setComponent, setFocusedInteractable
    • Field Detail

      • comboBox

        protected com.googlecode.lanterna.gui2.ComboBox<String> comboBox
        the combobox with the options.
      • result

        protected String result
        the chosen option.
    • Constructor Detail

      • OptionDialog

        public OptionDialog​(String title,
                            String description,
                            String[] options,
                            String initial)
        Default constructor, takes a title for the dialog and runs code shared for dialogs
        Parameters:
        title - Title of the window
        description - the description to display
        options - the options to display in a combobox
        initial - the initial value
      • OptionDialog

        public OptionDialog​(String title,
                            String description,
                            String[] options,
                            String initial,
                            Collection<com.googlecode.lanterna.gui2.Window.Hint> hints)
        Default constructor, takes a title for the dialog and runs code shared for dialogs
        Parameters:
        title - Title of the window
        description - the description to display
        options - the options to display in a combobox
        initial - the initial value
        hints - the window hints
    • Method Detail

      • onOK

        protected void onOK()
      • onCancel

        protected void onCancel()
      • showDialog

        public String showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI)
        Overrides:
        showDialog in class com.googlecode.lanterna.gui2.dialogs.DialogWindow
      • showDialog

        public static String showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI,
                                        String title,
                                        String description,
                                        String[] options,
                                        String initial)
        Shortcut for quickly showing a OptionDialog.
        Parameters:
        textGUI - GUI to show the dialog on
        title - Title of the dialog
        description - Description of the dialog
        initial - the initial selection
        Returns:
        The option the user selected, or null if the dialog was cancelled
      • showDialog

        public static String showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI,
                                        String title,
                                        String description,
                                        String[] options,
                                        String initial,
                                        Collection<com.googlecode.lanterna.gui2.Window.Hint> hints)
        Shortcut for quickly showing a OptionDialog.
        Parameters:
        textGUI - GUI to show the dialog on
        title - Title of the dialog
        description - Description of the dialog
        initial - the initial selection
        hints - the window hints
        Returns:
        The option the user selected, or null if the dialog was cancelled