Package jexer

Class 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 ...
         }
     
     
    • 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 window
        title - window title, will be centered along the top border
        caption - 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 window
        title - window title, will be centered along the top border
        caption - 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 window
        title - window title, will be centered along the top border
        caption - 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 class TWindow
        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