Class ComponentDialog

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

    public class ComponentDialog
    extends com.googlecode.lanterna.gui2.dialogs.DialogWindow
    Dialog for displaying a component.
    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.Component component
      the component to display.
      protected com.googlecode.lanterna.gui2.dialogs.MessageDialogButton result
      the button that was selected.
      • Fields inherited from class com.googlecode.lanterna.gui2.AbstractBasePane

        contentHolder, interactableLookupMap
    • Constructor Summary

      Constructors 
      Constructor Description
      ComponentDialog​(String title, String description, com.googlecode.lanterna.gui2.Component component)
      Default constructor, takes a title for the dialog and runs code shared for dialogs Shows OK and Cancel buttons.
      ComponentDialog​(String title, String description, com.googlecode.lanterna.gui2.Component component, boolean hasOK, boolean hasCancel, boolean hasClose)
      Default constructor, takes a title for the dialog and runs code shared for dialogs
      ComponentDialog​(String title, String description, com.googlecode.lanterna.gui2.Component component, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints)
      Default constructor, takes a title for the dialog and runs code shared for dialogs Shows OK and Cancel buttons.
      ComponentDialog​(String title, String description, com.googlecode.lanterna.gui2.Component component, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints, boolean hasOK, boolean hasCancel, boolean hasClose)
      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
      com.googlecode.lanterna.gui2.dialogs.MessageDialogButton getResult()
      Returns the button that was selected.
      protected void onCancel()  
      protected void onClose()  
      protected void onOK()  
      void setSize​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, double width, double height)
      Sets the width and height of the dialog according to the percentage of the overall available screen real estate.
      com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI)
      Shows the dialog.
      static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, com.googlecode.lanterna.gui2.Component component)
      Shortcut for quickly showing a OptionDialog.
      static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, com.googlecode.lanterna.gui2.Component component, boolean hasOK, boolean hasCancel, boolean hasClose)
      Shortcut for quickly showing a OptionDialog.
      static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, com.googlecode.lanterna.gui2.Component component, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints)
      Shortcut for quickly showing a OptionDialog.
      static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, com.googlecode.lanterna.gui2.Component component, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints, boolean hasOK, boolean hasCancel, boolean hasClose)
      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

      • component

        protected com.googlecode.lanterna.gui2.Component component
        the component to display.
      • result

        protected com.googlecode.lanterna.gui2.dialogs.MessageDialogButton result
        the button that was selected.
    • Constructor Detail

      • ComponentDialog

        public ComponentDialog​(String title,
                               String description,
                               com.googlecode.lanterna.gui2.Component component)
        Default constructor, takes a title for the dialog and runs code shared for dialogs Shows OK and Cancel buttons.
        Parameters:
        title - Title of the window
        description - the optional description, can be null
        component - the component to display
      • ComponentDialog

        public ComponentDialog​(String title,
                               String description,
                               com.googlecode.lanterna.gui2.Component component,
                               boolean hasOK,
                               boolean hasCancel,
                               boolean hasClose)
        Default constructor, takes a title for the dialog and runs code shared for dialogs
        Parameters:
        title - Title of the window
        description - the optional description, can be null
        component - the component to display
        hasOK - whether to display the OK button
        hasCancel - whether to display the Cancel button
        hasClose - whether to display the Close button
      • ComponentDialog

        public ComponentDialog​(String title,
                               String description,
                               com.googlecode.lanterna.gui2.Component component,
                               Collection<com.googlecode.lanterna.gui2.Window.Hint> hints)
        Default constructor, takes a title for the dialog and runs code shared for dialogs Shows OK and Cancel buttons.
        Parameters:
        title - Title of the window
        description - the optional description, can be null
        component - the component to display
        hints - the window hints
      • ComponentDialog

        public ComponentDialog​(String title,
                               String description,
                               com.googlecode.lanterna.gui2.Component component,
                               Collection<com.googlecode.lanterna.gui2.Window.Hint> hints,
                               boolean hasOK,
                               boolean hasCancel,
                               boolean hasClose)
        Default constructor, takes a title for the dialog and runs code shared for dialogs
        Parameters:
        title - Title of the window
        description - the optional description, can be null
        component - the component to display
        hints - the window hints
        hasOK - whether to display the OK button
        hasCancel - whether to display the Cancel button
        hasClose - whether to display the Close button
    • Method Detail

      • setSize

        public void setSize​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI,
                            double width,
                            double height)
        Sets the width and height of the dialog according to the percentage of the overall available screen real estate.
        Parameters:
        textGUI - for determining the maximum dimensions
        width - the width percentage (0-1) or number of columns (> 1)
        height - the height percentage (0-1) or number of rows (> 1)
      • onOK

        protected void onOK()
      • onCancel

        protected void onCancel()
      • onClose

        protected void onClose()
      • showDialog

        public com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI)
        Shows the dialog.
        Overrides:
        showDialog in class com.googlecode.lanterna.gui2.dialogs.DialogWindow
        Parameters:
        textGUI - the context
        Returns:
        the button that was selected
      • getResult

        public com.googlecode.lanterna.gui2.dialogs.MessageDialogButton getResult()
        Returns the button that was selected.
        Returns:
        the button
      • showDialog

        public static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI,
                                                                                          String title,
                                                                                          String description,
                                                                                          com.googlecode.lanterna.gui2.Component component)
        Shortcut for quickly showing a OptionDialog. Shows OK and Cancel buttons.
        Parameters:
        textGUI - GUI to show the dialog on
        title - Title of the dialog
        description - Description of the dialog
        component - the component
        Returns:
        the button that was selected
      • showDialog

        public static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI,
                                                                                          String title,
                                                                                          String description,
                                                                                          com.googlecode.lanterna.gui2.Component component,
                                                                                          Collection<com.googlecode.lanterna.gui2.Window.Hint> hints)
        Shortcut for quickly showing a OptionDialog. Shows OK and Cancel buttons.
        Parameters:
        textGUI - GUI to show the dialog on
        title - Title of the dialog
        description - Description of the dialog
        component - the component
        hints - the window hints
        Returns:
        the button that was selected
      • showDialog

        public static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI,
                                                                                          String title,
                                                                                          String description,
                                                                                          com.googlecode.lanterna.gui2.Component component,
                                                                                          boolean hasOK,
                                                                                          boolean hasCancel,
                                                                                          boolean hasClose)
        Shortcut for quickly showing a OptionDialog.
        Parameters:
        textGUI - GUI to show the dialog on
        title - Title of the dialog
        description - Description of the dialog
        component - the component
        hasOK - whether to display the OK button
        hasCancel - whether to display the Cancel button
        hasClose - whether to display the Close button
        Returns:
        the button that was selected
      • showDialog

        public static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog​(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI,
                                                                                          String title,
                                                                                          String description,
                                                                                          com.googlecode.lanterna.gui2.Component component,
                                                                                          Collection<com.googlecode.lanterna.gui2.Window.Hint> hints,
                                                                                          boolean hasOK,
                                                                                          boolean hasCancel,
                                                                                          boolean hasClose)
        Shortcut for quickly showing a OptionDialog.
        Parameters:
        textGUI - GUI to show the dialog on
        title - Title of the dialog
        description - Description of the dialog
        component - the component
        hints - the window hints
        hasOK - whether to display the OK button
        hasCancel - whether to display the Cancel button
        hasClose - whether to display the Close button
        Returns:
        the button that was selected