Class TextInputDialog
java.lang.Object
com.googlecode.lanterna.gui2.AbstractBasePane<Window>
com.googlecode.lanterna.gui2.AbstractWindow
com.googlecode.lanterna.gui2.dialogs.DialogWindow
com.googlecode.lanterna.gui2.dialogs.TextInputDialog
TextInputDialog is a modal text input dialog that prompts the user to enter a text string. The class supports
validation and password masking. The builder class to help setup TextInputDialogs is
TextInputDialogBuilder.-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractBasePane
AbstractBasePane.ContentHolderNested classes/interfaces inherited from interface Window
Window.Hint -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate final TextBoxprivate final TextInputDialogResultValidatorFields inherited from class AbstractBasePane
contentHolder, interactableLookupMap -
Constructor Summary
ConstructorsConstructorDescriptionTextInputDialog(String title, String description, TerminalSize textBoxPreferredSize, String initialContent, TextInputDialogResultValidator validator, boolean password) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidonCancel()private voidonOK()showDialog(WindowBasedTextGUI textGUI) Opens the dialog by showing it on the GUI and doesn't return until the dialog has been closedstatic StringshowDialog(WindowBasedTextGUI textGUI, String title, String description, String initialContent) Shortcut for quickly showing aTextInputDialogstatic BigIntegershowNumberDialog(WindowBasedTextGUI textGUI, String title, String description, String initialContent) Shortcut for quickly showing aTextInputDialogthat only accepts numbersstatic StringshowPasswordDialog(WindowBasedTextGUI textGUI, String title, String description, String initialContent) Shortcut for quickly showing aTextInputDialogwith password maskingMethods inherited from class AbstractWindow
addWindowListener, close, draw, fromGlobal, fromGlobalToContentRelative, fromGlobalToDecoratedRelative, getDecoratedSize, getHints, getPosition, getPostRenderer, getPreferredSize, getSize, getTextGUI, getTitle, handleInput, isVisible, removeWindowListener, setCloseWindowWithEscape, setContentOffset, setDecoratedSize, setFixedSize, setHints, setPosition, setSize, setTextGUI, setTitle, setVisible, setWindowPostRenderer, toGlobal, toGlobalFromContentRelative, toGlobalFromDecoratedRelative, waitUntilClosedMethods inherited from class AbstractBasePane
addBasePaneListener, getBasePaneListeners, getComponent, getCursorPosition, getFocusedInteractable, getMenuBar, getTheme, invalidate, isInvalid, removeBasePaneListener, setComponent, setEnableDirectionBasedMovements, setFocusedInteractable, setFocusedInteractable, setMenuBar, setStrictFocusChange, setThemeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BasePane
getTheme, setEnableDirectionBasedMovements, setStrictFocusChange, setThemeMethods inherited from interface Window
getBounds, getComponent, getCursorPosition, getFocusedInteractable, getMenuBar, invalidate, isInvalid, setComponent, setFocusedInteractable, setMenuBar
-
Field Details
-
textBox
-
validator
-
result
-
-
Constructor Details
-
TextInputDialog
TextInputDialog(String title, String description, TerminalSize textBoxPreferredSize, String initialContent, TextInputDialogResultValidator validator, boolean password)
-
-
Method Details
-
onOK
private void onOK() -
onCancel
private void onCancel() -
showDialog
Description copied from class:DialogWindowOpens the dialog by showing it on the GUI and doesn't return until the dialog has been closed- Overrides:
showDialogin classDialogWindow- Parameters:
textGUI- Text GUI to add the dialog to- Returns:
- Depending on the
DialogWindowimplementation, by defaultnull
-
showDialog
public static String showDialog(WindowBasedTextGUI textGUI, String title, String description, String initialContent) Shortcut for quickly showing aTextInputDialog- Parameters:
textGUI- GUI to show the dialog ontitle- Title of the dialogdescription- Description of the dialoginitialContent- What content to place in the text box initially- Returns:
- The string the user typed into the text box, or
nullif the dialog was cancelled
-
showNumberDialog
public static BigInteger showNumberDialog(WindowBasedTextGUI textGUI, String title, String description, String initialContent) Shortcut for quickly showing aTextInputDialogthat only accepts numbers- Parameters:
textGUI- GUI to show the dialog ontitle- Title of the dialogdescription- Description of the dialoginitialContent- What content to place in the text box initially- Returns:
- The number the user typed into the text box, or
nullif the dialog was cancelled
-
showPasswordDialog
public static String showPasswordDialog(WindowBasedTextGUI textGUI, String title, String description, String initialContent) Shortcut for quickly showing aTextInputDialogwith password masking- Parameters:
textGUI- GUI to show the dialog ontitle- Title of the dialogdescription- Description of the dialoginitialContent- What content to place in the text box initially- Returns:
- The string the user typed into the text box, or
nullif the dialog was cancelled
-