- 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
-
public class TextInputDialog extends DialogWindow
TextInputDialogis 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 setupTextInputDialogs isTextInputDialogBuilder.
-
-
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
Fields Modifier and Type Field Description private java.lang.Stringresultprivate TextBoxtextBoxprivate TextInputDialogResultValidatorvalidator-
Fields inherited from class com.googlecode.lanterna.gui2.AbstractBasePane
contentHolder, interactableLookupMap
-
-
Constructor Summary
Constructors Constructor Description TextInputDialog(java.lang.String title, java.lang.String description, TerminalSize textBoxPreferredSize, java.lang.String initialContent, TextInputDialogResultValidator validator, boolean password)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidonCancel()private voidonOK()java.lang.StringshowDialog(WindowBasedTextGUI textGUI)Opens the dialog by showing it on the GUI and doesn't return until the dialog has been closedstatic java.lang.StringshowDialog(WindowBasedTextGUI textGUI, java.lang.String title, java.lang.String description, java.lang.String initialContent)Shortcut for quickly showing aTextInputDialogstatic java.math.BigIntegershowNumberDialog(WindowBasedTextGUI textGUI, java.lang.String title, java.lang.String description, java.lang.String initialContent)Shortcut for quickly showing aTextInputDialogthat only accepts numbersstatic java.lang.StringshowPasswordDialog(WindowBasedTextGUI textGUI, java.lang.String title, java.lang.String description, java.lang.String initialContent)Shortcut for quickly showing aTextInputDialogwith password masking-
Methods 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 Detail
-
textBox
private final TextBox textBox
-
validator
private final TextInputDialogResultValidator validator
-
result
private java.lang.String result
-
-
Constructor Detail
-
TextInputDialog
TextInputDialog(java.lang.String title, java.lang.String description, TerminalSize textBoxPreferredSize, java.lang.String initialContent, TextInputDialogResultValidator validator, boolean password)
-
-
Method Detail
-
onOK
private void onOK()
-
onCancel
private void onCancel()
-
showDialog
public java.lang.String showDialog(WindowBasedTextGUI textGUI)
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 java.lang.String showDialog(WindowBasedTextGUI textGUI, java.lang.String title, java.lang.String description, java.lang.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 java.math.BigInteger showNumberDialog(WindowBasedTextGUI textGUI, java.lang.String title, java.lang.String description, java.lang.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 java.lang.String showPasswordDialog(WindowBasedTextGUI textGUI, java.lang.String title, java.lang.String description, java.lang.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
-
-