Package jexer
Class TMessageBox
- java.lang.Object
-
- jexer.TWidget
-
- jexer.TWindow
-
- jexer.TMessageBox
-
- All Implemented Interfaces:
java.lang.Comparable<TWidget>
- Direct Known Subclasses:
TInputBox
public class TMessageBox extends TWindow
TMessageBox is a system-modal dialog with buttons for OK, Cancel, Yes, or No. Call it like:box = messageBox(title, caption, TMessageBox.Type.OK | TMessageBox.Type.CANCEL); if (box.getResult() == TMessageBox.OK) { ... the user pressed OK, do stuff ... }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TMessageBox.Result
Message boxes have these possible results.static class
TMessageBox.Type
Message boxes have these supported types.
-
Field Summary
Fields Modifier and Type Field Description protected TMessageBox.Result
result
Which button was clicked: OK, CANCEL, YES, or NO.-
Fields inherited from class jexer.TWindow
ABSOLUTEXY, CENTERED, helpTopic, HIDEONCLOSE, inKeyboardResize, inWindowMove, inWindowResize, MODAL, mouse, NOCLOSEBOX, NOZOOMBOX, overlay, OVERRIDEMENU, RESIZABLE, statusBar, underlay
-
-
Constructor Summary
Constructors Modifier Constructor Description TMessageBox(TApplication application, java.lang.String title, java.lang.String caption)
Public constructor.TMessageBox(TApplication application, java.lang.String title, java.lang.String caption, TMessageBox.Type type)
Public constructor.protected
TMessageBox(TApplication application, java.lang.String title, java.lang.String caption, TMessageBox.Type type, boolean yield)
Public constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TMessageBox.Result
getResult()
Get the result.boolean
isCancel()
See if the user clicked CANCEL.boolean
isNo()
See if the user clicked NO.boolean
isOk()
See if the user clicked OK.boolean
isYes()
See if the user clicked YES.void
onKeypress(TKeypressEvent keypress)
Handle keystrokes.-
Methods inherited from class jexer.TWindow
activate, addOverlay, addShortcutKeypress, addUnderlay, center, clearShortcutKeypresses, close, draw, ensureOnScreen, getApplication, getBackground, getBorder, getBorderControls, getHelpTopic, getMaximumWindowHeight, getMaximumWindowWidth, getMinimumWindowHeight, getMinimumWindowWidth, getScreen, getStatusBar, getTitle, getZ, hasCloseBox, hasHiddenMouse, hasOverriddenMenu, hasZoomBox, hide, inMovements, isHidden, isModal, isResizable, isShortcutKeypress, isShown, maximize, mouseOnClose, mouseOnMaximize, mouseOnResize, newStatusBar, onClose, onCommand, onFocus, onHide, onMenu, onMouseDown, onMouseMotion, onMouseUp, onPreClose, onResize, onShow, onUnfocus, removeShortcutKeypress, restore, setCloseBox, setHiddenMouse, setMaximumWindowHeight, setMaximumWindowWidth, setMinimumWindowHeight, setMinimumWindowWidth, setResizable, setTackboardsDirty, setTitle, setZ, setZoomBox, show, stopMovements, toString
-
Methods inherited from class jexer.TWidget
activate, activate, activateAll, addButton, addCalendar, addCheckBox, addCheckBox, addComboBox, addDirectoryList, addDirectoryList, addDirectoryList, addDirectoryList, addEditor, addField, addField, addField, addField, addImage, addImage, addLabel, addLabel, addLabel, addLabel, addLabel, addLabel, addList, addList, addList, addList, addPanel, addPasswordField, addPasswordField, addPasswordField, addProgressBar, addRadioGroup, addRadioGroup, addSpinner, addSplitPane, addTable, addTable, addText, addText, addTreeViewWidget, addTreeViewWidget, compareTo, doRepaint, drawBox, drawBox, drawBoxShadow, drawChildren, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getAttrXY, getChildren, getClipboard, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getCustomMousePointer, getHeight, getLayoutManager, getMouseStyle, getParent, getTheme, getWidgetUnderMouse, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isPixelMouse, isVisible, messageBox, messageBox, mouseWouldHit, onIdle, onMouseDoubleClick, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, putStringXY, putStringXY, remove, remove, remove, remove, removeAll, resetTabOrder, setActive, setCursorVisible, setCursorX, setCursorY, setCustomMousePointer, setDimensions, setEchoKeystrokes, setEchoKeystrokes, setEnabled, setHeight, setLayoutManager, setMouseStyle, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, vLineXY
-
-
-
-
Field Detail
-
result
protected TMessageBox.Result result
Which button was clicked: OK, CANCEL, YES, or NO.
-
-
Constructor Detail
-
TMessageBox
public TMessageBox(TApplication application, java.lang.String title, java.lang.String caption)
Public constructor. The message box will be centered on screen.- Parameters:
application
- TApplication that manages this windowtitle
- window title, will be centered along the top bordercaption
- message to display. Use embedded newlines to get a multi-line box.
-
TMessageBox
public TMessageBox(TApplication application, java.lang.String title, java.lang.String caption, TMessageBox.Type type)
Public constructor. The message box will be centered on screen.- Parameters:
application
- TApplication that manages this windowtitle
- window title, will be centered along the top bordercaption
- message to display. Use embedded newlines to get a multi-line box.type
- one of the Type constants. Default is Type.OK.
-
TMessageBox
protected TMessageBox(TApplication application, java.lang.String title, java.lang.String caption, TMessageBox.Type type, boolean yield)
Public constructor. The message box will be centered on screen.- Parameters:
application
- TApplication that manages this windowtitle
- window title, will be centered along the top bordercaption
- message to display. Use embedded newlines to get a multi-line box.type
- one of the Type constants. Default is Type.OK.yield
- if true, yield this Thread. Subclasses need to set this to false and yield at their end of their constructor intead.
-
-
Method Detail
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypress
in classTWindow
- Parameters:
keypress
- keystroke event
-
getResult
public final TMessageBox.Result getResult()
Get the result.- Returns:
- the result: OK, CANCEL, YES, or NO.
-
isYes
public final boolean isYes()
See if the user clicked YES.- Returns:
- true if the user clicked YES
-
isNo
public final boolean isNo()
See if the user clicked NO.- Returns:
- true if the user clicked NO
-
isOk
public final boolean isOk()
See if the user clicked OK.- Returns:
- true if the user clicked OK
-
isCancel
public final boolean isCancel()
See if the user clicked CANCEL.- Returns:
- true if the user clicked CANCEL
-
-