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 TextInputDialog
s is
TextInputDialogBuilder
.-
Nested Class Summary
Nested classes/interfaces inherited from class com.googlecode.lanterna.gui2.AbstractBasePane
AbstractBasePane.ContentHolder
Nested classes/interfaces inherited from interface com.googlecode.lanterna.gui2.Window
Window.Hint
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private final TextBox
private final TextInputDialogResultValidator
Fields inherited from class com.googlecode.lanterna.gui2.AbstractBasePane
contentHolder, interactableLookupMap
-
Constructor Summary
ConstructorsConstructorDescriptionTextInputDialog
(String title, String description, TerminalSize textBoxPreferredSize, String initialContent, TextInputDialogResultValidator validator, boolean password) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
onCancel()
private void
onOK()
showDialog
(WindowBasedTextGUI textGUI) Opens the dialog by showing it on the GUI and doesn't return until the dialog has been closedstatic String
showDialog
(WindowBasedTextGUI textGUI, String title, String description, String initialContent) Shortcut for quickly showing aTextInputDialog
static BigInteger
showNumberDialog
(WindowBasedTextGUI textGUI, String title, String description, String initialContent) Shortcut for quickly showing aTextInputDialog
that only accepts numbersstatic String
showPasswordDialog
(WindowBasedTextGUI textGUI, String title, String description, String initialContent) Shortcut for quickly showing aTextInputDialog
with password maskingMethods inherited from class com.googlecode.lanterna.gui2.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, waitUntilClosed
Methods inherited from class com.googlecode.lanterna.gui2.AbstractBasePane
addBasePaneListener, getBasePaneListeners, getComponent, getCursorPosition, getFocusedInteractable, getMenuBar, getTheme, invalidate, isInvalid, removeBasePaneListener, setComponent, setEnableDirectionBasedMovements, setFocusedInteractable, setFocusedInteractable, setMenuBar, setStrictFocusChange, setTheme
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.googlecode.lanterna.gui2.BasePane
getTheme, setEnableDirectionBasedMovements, setStrictFocusChange, setTheme
Methods inherited from interface com.googlecode.lanterna.gui2.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:DialogWindow
Opens the dialog by showing it on the GUI and doesn't return until the dialog has been closed- Overrides:
showDialog
in classDialogWindow
- Parameters:
textGUI
- Text GUI to add the dialog to- Returns:
- Depending on the
DialogWindow
implementation, 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
null
if the dialog was cancelled
-
showNumberDialog
public static BigInteger showNumberDialog(WindowBasedTextGUI textGUI, String title, String description, String initialContent) Shortcut for quickly showing aTextInputDialog
that 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
null
if the dialog was cancelled
-
showPasswordDialog
public static String showPasswordDialog(WindowBasedTextGUI textGUI, String title, String description, String initialContent) Shortcut for quickly showing aTextInputDialog
with 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
null
if the dialog was cancelled
-